drop table tab1 purge;
create table tab1(col1 char(1));
insert into tab1 values('a');
insert into tab1 values('a');
insert into tab1 values('a');
commit;
create or replace procedure myProc(inChar in char, outCur out sys_refcursor)
is
tmpChar char(1);
begin
--check for data before the rest of the code
begin
select 'x' into tmpChar from tab1 where col1=inChar and rownum=1;
exception
when NO_DATA_FOUND then
raise_application_error(-20002, 'No data found. Cannot continue.');
end;
open outCur for select col1 from tab1 where col1=inChar;
end;
/
show errors
--test using SQL*Plus variables
var myCur refcursor
exec myProc('a',:myCur);
print myCur
exec myProc('b',:myCur);
|