RowCount Object?
CharlovOct 12 2010 — edited Oct 12 2010Dear 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