I have a stored procedure that currently has 3 cursors. One of them is definitely required, but the other 2 are used ONLY to get past the 'NO ROWS FOUND' ORA error when doing a SELECT INTO cluase.
The most rows the SELECT INTO will return is 1 (I know this from the data) - but there are definitely cases where I will get no results.
Is there no way I can use SELECT INTO with a 'do this if there are no rows found' clause? I do not want to use 2 extra cursors if I do not have to.
As Chrisrlong stated you can also put the SELECT INTO in a PL/SQL block with an exception handler. You also need to handle the TOO_MANY_ROWS exception.
Why don't you want to use the cursors? With cursors you don't have to change your code if the data changes and there are no or many rows returned. And with cursors the code is more easy to read and maintain, then with the different exception handlers.
Bookmarks