fetch one more column : COUNT(1) when you define your cursor.FOR rec_current_cursor in your_current_cursor LOOP dbms_output.put_line("Total record : " || rec_current_cursor.COUNT(1));
IF running time > xxtime THEN
END IF; END LOOP;
sorry lost OVER().pls. use COUNT(1) OVER()
fetch one more column : COUNT(1) OVER() Total_Num when you define your cursor.FOR rec_current_cursor in your_current_cursor LOOP ...
IF running time > xxtime THEN fnd_file.put_line(fnd_file.log, 'Total Record Processed : ' || your_current_cursor%ROWCOUNT; fnd_file.put_line(fnd_file.log, 'Total Record Fetched : ' || rec_current_cursor.Total_Num); END IF; END LOOP;
一个不错的思路!利用分析函数,在每一行上得到一个结果集总数的列,然后在游标中使用.BEGIN FOR I IN (SELECT EMP.*,COUNT(1) OVER() AS TOTAL FROM EMP) LOOP DBMS_OUTPUT.PUT_LINE(I.TOTAL); END LOOP; END;
SELECT COUNT(1) FROM 你的游标定义可以得到。处理游标的时候 I++也可以统计ROWCOUNT确实是当前的。
我循环处理cursor的结果集,当运行时间大于某个时间时,我就跳出loop,所以我可以得到处理了多少条记录
但是我还想知道cursor中一共有多少
dbms_output.put_line("Total record : " || rec_current_cursor.COUNT(1));
IF running time > xxtime THEN
END IF;
END LOOP;
...
IF running time > xxtime THEN
fnd_file.put_line(fnd_file.log,
'Total Record Processed : ' || your_current_cursor%ROWCOUNT;
fnd_file.put_line(fnd_file.log,
'Total Record Fetched : ' || rec_current_cursor.Total_Num);
END IF;
END LOOP;
一个不错的思路!利用分析函数,在每一行上得到一个结果集总数的列,然后在游标中使用.BEGIN
FOR I IN (SELECT EMP.*,COUNT(1) OVER() AS TOTAL FROM EMP) LOOP
DBMS_OUTPUT.PUT_LINE(I.TOTAL);
END LOOP;
END;