Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Pro*C/C++ Cursors - How to count the number of results.
In article <176ffe5.0107240105.6f6a0f48_at_posting.google.com>,
gregory_at_harmonycom.com says...
>
>Hi !
>I am using Pro*C/C++ and i've the following questions :
>
>* after i'm opening a cursor, how can i know how many
> rows were found without performing additional queries
> (like select count (...)) ?
>
we only know the answer to that AFTER you fetch the last row. We don't "preanswer" queries. Consider what the effects of:
select * from one_billion_row_table
would be otherwise. You have to fetch the data in order to know the cardinality of the result set.
>* what is more efficient, to use a cursor or a host array as
> output variable in the INTO clause of SELECT ?
>
select INTO's return
o at least one row
o at most one row
If you are asking for at least and at most one row, the select INTO is the proper way to go.
If you are getting 0, 1 or more rows -- a cursor with host arrays is the way to go.
You should not replace a select into with an explict cursor/fetch into an array since there is at least/most one row (no array needed).
>Thanks for answers !
>Gregory
>gregory_at_harmonycom.com
-- Thomas Kyte (tkyte@us.oracle.com) http://asktom.oracle.com/ Expert one on one Oracle, programming techniques and solutions for Oracle. http://www.amazon.com/exec/obidos/ASIN/1861004826/ Opinions are mine and do not necessarily reflect those of Oracle CorpReceived on Tue Jul 24 2001 - 08:54:34 CDT