Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: [Q]How to get row count in select stmt in OCI
Hi there,
>I'm programming with OCI.
>To get the select result, it calls oexec() and ofetch().
>My problem is that I have to know the result row numbers before calling
>ofetch().
>
>I think there would be some data structure that keep statistic information,
>but I cannot find it.
Regarding the Oracle documentation this data ist stored inside the
cursor used to perform the oexec(). But this area is only filled when
executing
insert, update or delete statements. It does not contain the exact row count
when executing a select statement :-(
>The easy way is to execute "select count(*).." before executing select
>statement,
>but it may cost too much. If anybody has an answer for it, please let me
>know...
As far as i know that is the only way of counting rows. Fortunately it is
not
expensive as Oracle caches the statements. If you build up your query from
the exactly the same where clause then the first query (count(*)) selects
some
rows that where cached in a kind of hitlist. The second query which gets the
columns only taks some milliseconds as the result is cached. The realy
importent
thing here is that the where clause is exactly the same.
It's like learning to fly: Take a nice day and try it.
Clemens Hoffmann Received on Tue Oct 26 1999 - 03:26:29 CDT