Oracle Community Network
i am using Select Into statement in my stored procedure to get the data from the table and use that .It works fine if the condition return the data But if the select statement does not return any row it gives an exception.
i need to use that data in a mail template.Kindly help
why not simply handle the exception ?
create procedure xxxx
select whatever into wherever ....
when no_data_found then do_something();
when others then raise;
Thannks for the Suggestion...this will solve my problem
But i just want to know that...Isn't there is any other better way to do it.
Try using decode.
select decode((select testId from test),null,1,2) from dual;
If the record set is NULL, you will get 1 as output.
Else you will get 2 as output.
for more info,
When using decode, don't forget to add
because if there are multiple records in result set, inner query will throw an error.