Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Cursor %NOTFOUND

User648426-OracleOct 29 2008 — edited Oct 29 2008
Hi ,

I am trying to determine if a cursor that does not return any rows, does it need to be explicity closed after opening and checking thet %NOTFOUND is true
For example,
Lets say I have a cursor
Cursor C_get_value is
SELECT col1 frpm table where condition1= 'true';

Now when I open my cursor as following:

OPEN C_get_value;
FETCH C_get_value INTO O_value;
IF C_get_value%NOTFOUND THEN
O_error_message := 'Invalid values ';
RETURN 1;
END IF;
CLOSE C_get_value;

Lets assume that C_get_value%NOTFOUND was true and the condition1 was never met for the select query.

Now do I need to explicitly close the cursor C_get_value before Return 1?

OPEN C_get_value;
FETCH C_get_value INTO O_value;
IF C_get_value%NOTFOUND THEN
O_error_message := 'Invalid values ';
CLOSE C_get_value;
RETURN 1;
END IF;
CLOSE C_get_value;

Please help me with this.

Thanks,
Neha
This post has been answered by 283014 on Oct 29 2008
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 26 2008
Added on Oct 29 2008
4 comments
1,630 views