Hello,
I have created one for loop cursor and trying to get a count of records in a loop like:
declare
v_count number := 0;
v_char varchar2(2000);
begin
for i in (select count(*) over() as l_count,e.empno,e.ename,e.job,e.sal,e.deptno from emp e) loop
v_count := v_count + 1;
v_char := v_char||','||i.ename;
if v_count = i.l_count then
dbms_output.put_line('error msg'||'-->'||ltrim(v_char,',')); -- I want to raise exception here to get error message in orignal requirment
end if;
end loop;
end;
Above code is working fine but is it ok if we consider the performance of the query or is it a right way to get a count in for loop cursor?
Is there any other way to do the same in for loop cursor?
Thanks for the help.