oracle 如何从shell执行oracle程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18527116/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 01:53:33  来源:igfitidea点击:

How to execute a oracle procedure from shell

oraclecygwin

提问by lucifer

I have a stored procedure in oracle i want to call that procedure from cygwin. This is the procedure

我在 oracle 中有一个存储过程,我想从 cygwin 调用该过程。这是程序

CREATE OR REPLACE PROCEDURE greetings
AS
BEGIN
 dbms_output.put_line('Hello World!');
 END;

i am doing this

我在做这个

sqlplus -s system@orcl/oracle10g<<END
execute greetings();
commit;
exit;
END

回答by chance

Connect Oracle using SqlPlus, then run the procedure like this:

使用 SqlPlus 连接 Oracle,然后运行如下程序:

execute package_name.procedure_name (parameters...)

If you want to call sqlplus from within Windows shell:

如果要从 Windows shell 中调用 sqlplus:

@echo execute some_procedure | sqlplus username/password@databasename

(See this question)

(见这个问题

On Unix, try this:

在 Unix 上,试试这个:

echo "execute <some_procedure>" | sqlplus -s username/password@host:1521/service 

回答by schurik

try to add

尝试添加

set serveroutput on 

before execute greetings();

在执行 greetings() 之前;

回答by lucifer

sqlplus -s system/oracle10g@orcl @proc.sql this is working fine where system is my oracle username oracle10g is my pass and orcl is the localhost and the proc.sql is the file name where the procedure is stored.All we have to do is to go to specific directory from shell then execute this script

sqlplus -s system/oracle10g@orcl @proc.sql 这工作正常,系统是我的 oracle 用户名 oracle10g 是我的通行证,orcl 是本地主机,proc.sql 是存储过程的文件名。我们只需要做的是从shell转到特定目录然后执行此脚本