Re: Number of Rows in a Select --- How?
Posted in 1996
Rajendra Singh wrote:
>
> I am doing the following in ESQL/C using SE:
> - preparing a statement
> - declaring a cursor for it
> - opening the cursor
>
> The statement is something like "select * from x where y = z"
>
> How do I determine how many rows will be fetched? <SNIP>
There is no instant count, that would be an overhead.
You need to prepare and declare a second cursor something like:
SELECT COUNT(*) FROM x WHERE y = z
This will return one INTEGER.
Alternatively, you could fetch all records from your cursor, counting as
you go.
The COUNT(*) will generally give best results in terms of performance,
providing you've been running your UPDATE STATISTICS regularly.
Cheers,
--
Mark.
+-------------------------------------------------------------------------+
|Mark D. Stock - The West Solutions Group http://www.west.co.za |
| |
|Email: marks@west.co.za +------------------------------------------------+
|Tel: +27 11 803 2151 |If it doesn't work... force it! |
|Fax: +27 11 803 2189 |If it breaks... it needed replacing anyway! |
|Cell: +27 83 250 2325 |Well, that's how I code anyway! |
+------------------------+------------------------------------------------+