as it happens in enclosed blocks
If an anonymous block calls a function that raises exceptions, those are neither shown on console nor trapped in enclosing blocks…
What’s more, after being caught by handler in the function, lines after function call in the anonymous block are executed normally!
The called procedure is:
CREATE OR REPLACE PROCEDURE qt(pno number, qty OUT number)
IS
BEGIN
select sum(qty_on_hand) into qty from products where productno=pno;
END;
The calling block is:
DECLARE
qty number;
BEGIN
qt(&pno, qty);
dbms_output.put_line('qty is: '||qty);
END;
In case of invalid product number, no error is shown; why?
In your specific example, I think that no exception is being raised at all. You say “in the case of an invalid product number”, by which I assume you mean a product number that does not exist. That sounds like you expect your query to throw NO_DATA_FOUND, but since it is using an aggregate function without a GROUP BY, it will actually return a single row containing
NULLif there are no matching rows.