Hi all,
Thanks for your clarifications...
----- Original Message -----
From: "Paul DuBois" <[EMAIL PROTECTED]>
To: "Rajanath Tadikonda" <[EMAIL PROTECTED]>; "Mark Thornber"
<[EMAIL PROTECTED]>; "Sterin, Ilya" <[EMAIL PROTECTED]>; "Ilya Dyakov"
<[EMAIL PROTECTED]>
Cc: "DBI USERS" <[EMAIL PROTECTED]>
Sent: Friday, June 29, 2001 10:39 AM
Subject: Re: Returned value error
> At 10:30 AM -0700 6/29/01, Rajanath Tadikonda wrote:
> >Hi,
> >I executed the code in Windows environment and it is returning number of
> >rows with the help of
> >$sth->rows
> >or
> >$rv=$sth->execute;
> >These two statements are returning number of rows returned without any
> >problem in Windows Enviroment but in the case of Unix (Sun OS 5.8 we are
> >using) it is returning number of rows as 0E0 and there are rows in the
Table
> >that is very annoying .
>
> perldoc DBI says, first:
>
> For `SELECT' statements, execute simply "starts" the
> query within the database 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
> databases can't tell in advance), it simply returns a
> true value.
>
> And, second:
>
> `rows'
> $rv = $sth->rows;
>
> Returns the number of rows affected by the last row
> affecting command, or -1 if the number of rows is not
> known or not available.
>
> Generally, you can only rely on a row count after a
> non-`SELECT' `execute' (for some specific operations
> like `UPDATE' and `DELETE'), or after fetching all the
> rows of a `SELECT' statement.
>
> For `SELECT' statements, it is generally not possible
> to know how many rows will be returned except by
> fetching them all. Some drivers will return the
> number of rows the application has fetched so far, but
> others may return -1 until all rows have been fetched.
> So use of the `rows' method or `$DBI::rows' with
> `SELECT' statements is not recommended.
>
> So I'd say that according to the documentation, you're taking
> your chances by writing your code as you are. Count the rows
> yourself, or perhaps use a method such as selectall_arrayref()
> that returns a result from which you can determine the number of
> rows, or else perhaps issue a select COUNT(*) query...
>
> >
> >Rajanath
> >----- Original Message -----
> >From: "Mark Thornber" <[EMAIL PROTECTED]>
> >To: "Rajanath Tadikonda" <[EMAIL PROTECTED]>
> >Cc: "DBI USERS" <[EMAIL PROTECTED]>
> >Sent: Friday, June 29, 2001 1:24 AM
> >Subject: Re: Returned value error
> >
> >
> >> Rajanath,
> >>
> >> Look in the fine perldoc for DBI. "0E0" is TRUE and no error but zero
> >> rows.
> >>
> >>
> >> --MarkT
> >>
> >> Rajanath Tadikonda wrote:
> >> >
> >> > Hi all ,
> >> > I am trying to get a returned value in $rv and based on query using
> >oracle
> >> > ..
> >> > This query is returning properly the number of records retr'ved
> >without
> >> > any problem
> >> > but if I try the same code in Unix it is returning "0E0";
> >> >
> >> > I will appreciate if any one with similar experiance
> >> >
> >> > Thank
> >> > Rajanath
> >> > #!/usr/bin/perl
> >> > use DBI qw(:sql_types);
> >> >
> >> > my %dbx=getDetails();
> >> > my %attr = (PrintError => 0,RaiseError =>0,AutoCommit=>0);
> >> > my $rv=0;
> >> > $xctr++;
> >> >
> >> > my($usr,$pass,$drv,$connect_string) =
> >> > ($dbx{DB_USERNAME},$dbx{DB_PASSWD},$dbx{
> >> >
> >> > my ($dbh,$status1,$err)=&oraon($usr,$pass,$drv,$connect_string);
> >> >
> >> > if(!$status1)
> >> > {
> >> > &beta_error_page($err);
> >> >
> >> > exit(0);
> >> > }
> >> >
> >> > $dbh->{LongReadLen}=4096*1024;
> >> >
> >> > my $sql2="select req_id,user_id,prog_id,file_data,status from
> >> > fms_contact_impo
> >> >
> >> > my $sth=$dbh->prepare($sql2);
> >> >
> >> > if(!$sth)
> >> > {
> >> > &beta_error_page($DBI::errstr);
> >> >
> >> > exit(0);
> >> > }
> >> >
> >> > my $rv=$sth->execute();
> >> > print " Returned values is $rv \n";
> >> > exit(0);
> >>
>
>
> --
> Paul DuBois, [EMAIL PROTECTED]
>