您好我正在尝试从我的Shell脚本执行PL SQL过程并获取返回值(输出值),但它不起作用。谁能告诉我我做错了什么?这就是我所拥有的:
output="$(sqlplus -S user/pw@//ip:1521/db <<ENDOFSQL
set serveroutput on;
DECLARE
v_return PLS_INTEGER;
BEGIN
PKG.Procedure(v_return);
DBMS_OUTPUT.PUT_LINE(v_return);
END;
exit;
ENDOFSQL)"
echo $output
答案 0 :(得分:3)
经过一整天的反复试验后,我终于得到了以下脚本:
#!/bin/ksh
CODE=`sqlplus -S $SCHEMA/$PW@//$IP_PORT/$DB << EOM
Set timing on
Set serveroutput on
Whenever sqlerror exit failure;
Whenever oserror exit failure;
declare
v_return number;
begin
PKG.Procedure(v_return);
end;
/
EOM`
if [ $? != 0 ]
then
echo "process failed."
exit 1
fi
exit $?