Reputation: 3118
How I can know cursor size (numbers of results)?
c CURSOR IS SELECT foo FROM mytable WHERE name='ok';
Upvotes: 3
Views: 6624
Reputation: 289
If you want to obtain the total number of results without issuing a separate count query, you can:
SELECT count(1) OVER (), ... FROM ... WHERE ...
The count will be unaffected by ORDER/LIMIT clauses.
Upvotes: 3
Reputation: 2060
In my understanding, a cursor is NOT the result. You can use a cursor to GET your results row by row, and at the end of this row by row operations, you know how many results you got.
To know how many records you will (possibly) get, you can use a
select count(*) from ... where ...
assuming you have an index on column name, you could also write:
select count(name) from foo where name = 'ok'
Upvotes: 2