Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Oracle8, Perl, and query question

Re: Oracle8, Perl, and query question

From: Vartan Narinian <vsn_at_pobox.com>
Date: Sat, 14 Apr 2001 12:49:54 +0100
Message-ID: <8aegdt4o1be0jg8kenqutmrrfqqc9sj72k@4ax.com>

mwilson_at_symantec.com writes:
>
>Hello,
>I'm helping a co-worker get some legacy cgi scripts written in Perl
>migrated from MySQL to Oracle8. We used to be able to get the number
>of rows returned from a query back as the return value when executing
>a statement handle. Now that we're using Oracle, the value returned
>is 0E0, $sth->rows returns 0 as well. I've looked and looked and have
>yet to find any reference to this 'feature'. Can anyone who is currently
>using DBI and Oracle let me know what's going on? Is there an easy
>means of getting the number of rows returned from a query? Thanks in
>advance!
>-Mark Wilson.

Hi Mark,

Have you RTFM'd (Read The Fine Manual) ?

Pay particular attention to the last paragraph...

execute

      $rv = $sth->execute                || die $sth->errstr;
      $rv = $sth->execute(@bind_values)  || die $sth->errstr;

    Perform whatever processing is necessary to execute the prepared     statement. An undef is returned if an error occurs, a successful     execute always returns true regardless of the number of rows     affected (even if it's zero, see below). It is always important to     check the return status of execute (and most other DBI methods)     for errors.

    For a non-select statement, execute returns the number of rows     affected (if known). If no rows were affected then execute returns     "0E0" which Perl will treat as 0 but will regard as true. Note     that it is not an error for no rows to be affected by a statement.     If the number of rows affected is not known then execute returns     -1.

    For select statements execute simply 'starts' the query within the     Engine. Use one of the fetch methods to retreive the data after     calling execute. The execute method does not return the number of     rows that will be returned by the query (because most Engines     can't tell in advance), it simply returns a true value.

So I guess you don't know until you have fetched them all.

Regards,

-- 
Vartan
Received on Sat Apr 14 2001 - 06:49:54 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US