Hi All,

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

Thanks

Views: 53

Replies to This Discussion

why not simply handle the exception ?

create procedure xxxx
...
begin
....
begin
select whatever into wherever ....
do_something();
exception
when no_data_found then do_something();
when others then raise;
end;
end xxxx;
/

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.

Thanks

Try using decode.
tableName: test

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,
http://eoracle11g.blogspot.com/

When using decode, don't forget to add
where rownum<2

because if there are multiple records in result set, inner query will throw an error.

RSS

Oracle Jobs in US

© 2024   Created by Maisam Agha.   Powered by

Badges  |  Report an Issue  |  Terms of Service