If you call a function from SQL and the function calls NO_DATA_FOUND, you get NULL.
The SQLCODE of NO_DATA_FOUND is +100, while the PL / SQL code is -1403. Link
A positive number is not an error, and SQL does not consider the concept of NO_DATA_FOUND as an exception. SQL considers this "No Value", which is null.
create or replace function ret_dt return date is begin raise no_data_found; end; / Elapsed: 00:00:00.26 > select rownum ,ret_dt from user_tables where rownum < 5; ROWNUM RET_DT --------------- ----------------- 1.00 2.00 3.00 4.00
You probably want to catch it and return a specific value, or catch it, and throw a custom exception (depending on what you want).
source share