在我的存储过程中,我有两个查询:
这里,rec_count是out参数,cursor_name是out参数。
open cursor_name for
select <col list> from <table1 join table2 inner join...> on <join conditions> where <conditions>;
select count(*) into rec_count from <table1 join table2 inner join...> on <join conditions> where <conditions>;发布于 2015-03-12 17:53:53
你可以像这样对整个数据进行分析计数-
OPEN cursor_name for
SELECT <col_list> ,
count(*) over () as cnt
from <tables> <join conditions> <where clauses>;这样,游标将有一个列,其中包含每一行中所有行的计数。
发布于 2015-03-12 18:07:45
有比你想象的更大的问题在这里。
如果另一个会话提交了一个事务,同时打开游标并选择count,该怎么办?显然,游标的行的count将与选择的count(*)查询不匹配。
直到获取最后一行时,Oracle才知道行数。
如果您想要精确的行数,那么我将坚持在您现有的游标查询中使用analytic count(*) over()。
https://stackoverflow.com/questions/29016759
复制相似问题