Function in shell [message #195021] |
Tue, 26 September 2006 11:21 |
uicmxz
Messages: 48 Registered: July 2006
|
Member |
|
|
How I can check return value from PL/SQL function in shell script?
I have function in the package that returns status (1 - success, 2 - failed) of execute procedures which truncate table.
First I execute procedures in the shell script that truncate table. Then I call function to check status.
I would like to return status value from function to shell.
sqlplus ${pbmuser} <<EOF
EXEC BATCH_DDL.TRUNCATE_TABLE('RETR_TEMP');
EOF
sqlplus ${pbmuser} >> $logfile <<EOF
set serveroutput on
set feedback off
declare
status number;
begin
status := batch_ddl.get_exit_code'RETR_TEMP','TRUNCATE_TABLE' );
if ( status = 0 ) then
dbms_output.put_line( 'successful' );
else
dbms_output.put_line( 'faild' );
end if;
end;
/
EOF
Thanks
|
|
|
|
Re: Function in shell [message #195119 is a reply to message #195073] |
Wed, 27 September 2006 02:21 |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
Or you can use the EXIT command which allows you to pass back a bind variable.
Try something like:
(untested)
set serveroutput on
set feedback off
variable e_stat number
begin
:e_status := batch_ddl.get_exit_code'RETR_TEMP','TRUNCATE_TABLE' );
if ( status = 0 ) then
dbms_output.put_line( 'successful' );
else
dbms_output.put_line( 'faild' );
end if;
end;
/
EXIT :e_stat
|
|
|