Friday, 7 January 2011

PL/sql function and no_data_found

PL/SQL functions with a 'select col1 into v1 from table' line in them behave differently when they hit a no_data_found error (i.e. if the table is empty).
IF
you call the function like this .....
BEGIN
my_function;
END;
THEN
YOU get a no_data_found exception raised.


BUT
IF YOU CALL THE FUNCTION LIKE THIS....
SELECT my_function FROM dual;
THEN
It will not raise a no_data_found

see
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:317260900346187160