Toad World® Forums

exception when no_data_found then


#1

So far I have tried to use NO_DATA_FOUND, but it is not working.

Could you help me please?

create or replace procedure sp_select

(p_id_g in t_dml.id_g%type,
c_select out sys_refcursor
)
is
begin
open c_select for select id_g, id_d
from t_dml
where id_g = p_id_g;

exception
when no_data_found then
dbms_output.put_line (‘No data found.’);

end sp_select;


#2

This not not a Toad question, so it really doesn’t belong in this forum, so I would recommend looking at Oracle documentation on ref cursors for more examples. But, in general, if I’m understanding you correctly, you expect the no_data_found to be raised if the cursor doesn’t find any data, but a cursor will not throw an exception if it doesn’t find any rows. Google any of these keywords and you should get plenty of examples back SYS_REFCURSOR, %FOUND, %NOTFOUND, %ISOPEN, and %ROWCOUNT.