sqloracle-databasestored-procedurescursorsqlcode

Sqlcode of the cursor query in oracle


I have a oracle cursor with query

CURSOR cursor IS SELECT column1 FROM table_name WHERE column1 = 48200;
DBMS_OUTPUT.PUT_LINE(SQLCODE);

I need the SQLCODE of the query in the cursor. I wrote without cursor then i can get the SQLCODE but i need the SQLCODE with the CURSOR.

SELECT column1 FROM table_name WHERE column1 = 48200;
DBMS_OUTPUT.PUT_LINE(SQLCODE);

here I can able to get the SQLCODE as 0 for 'data found' and 100 for 'no data found'


Solution

  • That won't work for a cursor. You should use cursor_name%FOUND or cursor_name%NOTFOUND instead.