John Scoles wrote:
>> [EMAIL PROTECTED] wrote:
>>> Anyone knows if DBD::Oracle has a function similar to the function
>>> $sth->rows that exist in DBD::Mysql?
>>
>> This is a DBI feature. It exists for all drivers.
>>
>>> This function give us the number o rows in a select command. So, we
>>> don“t have to run a fetchrow with a while loop to know how many rows
>>> the select will return.
>>
>> This is driver-specific behavior. The DBI does not guarantee this.
>> With Oracle, you will need to either (1) fetch all the rows first, or
>> (2) change your SQL to "select count(1) from ...".
>
Oracle doesn't have this feature so DBD::Oracle doesn't either.
This has cropped up many times before So you can blame Oracle on that.
Thier logic (as it was explained to me) is
"How could you get the number of rows you are going to fetch without
counting them all first?"
Oracle sort of does have the feature if you ask for it; call OCIExecute
with OCI_STMT_SCROLLABLE_READONLY, and use OCIStmtFetch2 with
OCI_FETCH_LAST to skip to the last row without fetching all the other
data, and read OCI_ATTR_ROW_COUNT off the statement handle to get the
number of rows (and then probably OCIStmtFetch2 + OCI_FETCH_FIRST to
seek back to the start so the rest works as normal).
Whether it's worth the overhead is another question (the manual has
various performance warnings on the scrollable cursor feature) but it is
available.
--
Andy Hassall :: [EMAIL PROTECTED] :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool