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!

sqlcode and sql%rowcount as test conditions

sgonos-OracleJul 22 2010 — edited Jul 22 2010
I am translating a procedure from Ingres to oracle. I use the Oracle sqlcode and sql%rowcount
variables in place of Ingres's iierrornumber and iirowcount.

I replaced the ingres names with the oracle names, and now am wondering how how oracle uses these
values.

I am using DBMS_OUTPUT.PUT_LINE to display the contents of sqlcode and sql%rowcount.

What happens when I get "no rows selected". I run the same query in standalone command line
and get no rows selected .. and it's correct because I don't have data that matches).

But when I run it in the procedure, I don't get any values in sqlcode or sql%rowcount ... the
program just exits. The author was using the ingres code to test if there was data there and then
continue to do something else.

If you get no rows returned, does that mean, the sqlcode is 0 ? and the sql%rowcount is emtpy?
which is why my DBMS_OUTPUT.PUT_LINE doesn't display anything ?

my example........

before this section in the procedure ... after running a different select that returns data ...
I am using the DBMS to debug the values I have going in ...

DBMS_OUTPUT.Put_line ('BEFORE sqlcode is' || sqlcode);
DBMS_OUTPUT.Put_line ('BEFORE sqlrowcount is' || sql%rowcount);

Select value from table
where condition ='Y'; > this select will product "no rows return" and ignore the 2 DBMS_OUTPUTS beow ---

DBMS_OUTPUT.Put_line ('AFTER sqlcode is' || sqlcode);
DBMS_OUTPUT.Put_line ('AFTER sqlrowcount is' || sql%rowcount);

When i run the procedure... I get the DBMS BEFORE statements, and nothing afterwards ...
BEFORE sqlcode is 0
BEFORE sqlrowcount is 1 >>>> that is all that displays


Since I am getting the "no rows returned" ... how does oracle handle it to anyone's experience ?

Thank you. I am learning much from your comments and information.
This post has been answered by Tubby on Jul 22 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 19 2010
Added on Jul 22 2010
5 comments
3,252 views