Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Setting exit status in PLSQL

572704Sep 13 2010 — edited Sep 13 2010
Hi All,

Is there a way I can set exit status of PLSQL code to particular value depending on the satisfying condition.

For example consider following code:

set serveroutput on;

declare
app_id_cnt number;
app_name_cnt number;
sql_exit_sts number := 0;

begin

select count(app_id) into app_id_cnt from apps;
select count(app_name) into app_name_cnt from apps where app_name = 'BB';

dbms_output.put_line(app_id_cnt);
dbms_output.put_line(app_name_cnt);

if app_id_cnt = app_name_cnt
then
dbms_output.put_line('Success');
else

dbms_output.put_line('Failure');
sql_exit_sts := 213;
end if;

--return(sql_exit_st);
dbms_output.put_line(sql_exit_sts);


if sql_exit_sts = 213
then
exit 213;
else
exit 0;
end if;

end;

/

The above code doesn't work. My aim is to make plsql code exit with 213 if a particular condition is satisfied or else exit with default set value of 0.
This post has been answered by Herald ten Dam on Sep 13 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 11 2010
Added on Sep 13 2010
5 comments
8,262 views