Shell 获得 存储过程 返回值 在线等......
现在有一需求:通过Shell调用存储过程,执行一些功能,调用存储过程时要能在Shell中获得该存储过程是否执行成功,于是我想在存储过程中使用exception,假如sql执行有异常,就返回一个值1,执行成功就返回0,现在的问题是:我怎么从Shell里面获得存储过程的返回值?
存储过程:
create or replace procedure FUNC_DATA_DELETE
(TableName in varchar2,
KeepDays in number,ret in out number)
as
begin
delete from t_Vlanconfig t ;
ret:=0;
exception
when others then
ret:=1;
commit;
end;
shell:
里面的具体获得不知道怎么写
先写一部分
#!/usr/bin/sh
echo "begin ......"
echo exec FUNC_DATA_DELETE\(\'$1\',$2,$a\) | sqlplus LPDB_DUAN/LPDB_DUAN@hpsa
echo 'a:'$a
echo $?
求教高手.......
[解决办法]
LZ是想活的管道符前面命令的返回值吗?
[解决办法]
试试这样
#!/bin/shecho "begin ......"result=`sqlplus LPDB_DUAN/LPDB_DUAN@hpsa <<EOFcreate or replace procedure FUNC_DATA_DELETE (TableName in varchar2, KeepDays in number,ret in out number) as begin delete from t_Vlanconfig t ; ret:=0; exception when others then ret:=1; commit;end;EOF`echo $result
[解决办法]
create or replace procedure z17 (ret out number) as
begin
ret:=1;
dbms_output.put_line(ret);
end;
#!/bin/kshoo=`sqlplus -s gdtelrate/gdtelrate@jfzw54 <<!set serveroutput onset feedback offdeclare a number;beginz17(a);end;/!`echo $oo