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!

RowCount Object?

CharlovOct 12 2010 — edited Oct 12 2010
Dear all,
Is there a way to know, in PL/SQL, how many records the query returns, without calling it again with a count(*) function?

This is the code that I am using:
In case the query returns 0 rows, the resultset will be nil, therefore, the ELSE clause will not be accessed.

FOR I in (select col1, TO_STRING(CAST(COLLECT((CAST(Col2 AS VARCHAR2(4000))) ) AS varchar2_ntt)) AS OutPut
from table t
where t.status != 'DEACTIVATED'
group by col1) LOOP

IF i.OutPut IS NOT NULL THEN
dbms_output.Put_Line ( Col1 || ' ' Col2);
ELSE
dbms_output.Put_Line ( '0 Cols Added');
END IF;
end loop;


Thanks
This post has been answered by Saubhik Banerjee on Oct 12 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 9 2010
Added on Oct 12 2010
3 comments
101 views