0

我有一个添加两个数字的过程。我想从 shell 调用该过程。我可以在没有参数的情况下调用过程。例如

 create or replace procedure printTheName
  is 
  begin
 dbms_output.put_line('This is a procedure'):
 end;
 /

这是打印消息的程序。我可以使用它从 shell 调用它

#!/bin/sh
sqlplus -s system/oracle10g@orcl<<END
execute printTheName();
commit;

这运行良好现在我有一个添加两个数字的程序,我必须从 shell 调用它,这就是程序。

declare
  a number(2);
  b number(2);
  c number(2);
begin
  a:=&a;
  b:=&b;
  c:=a+b;
  dbms_output.put_line(a|| ' + '||b||' = '||c);
end;
4

2 回答 2

0

使用管道将命令传递给sqlplus

echo "execute printTheName(10,10);
commit;
execute procedure2();
" | sqlplus system/oracle10g@orcl

请注意,您不能在双引号内放置任意数量的sqlplus命令。

于 2013-09-03T13:09:55.573 回答
0

Lucifer,重定向到输出:

{ 
echo "execute printTheName(10,10);
commit;
execute procedure2();
" | sqlplus system/oracle10g@orcl 
} > fileout.txt
于 2016-10-25T19:45:27.550 回答