Skip to Content.
Sympa Menu

freetds - Re: [freetds] $sth->rows returns nothing ??

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Frediano Ziglio <freddyz77 AT tin.it>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] $sth->rows returns nothing ??
  • Date: 29 Apr 2003 22:03:26 +0200

Il mar, 2003-04-29 alle 21:50, Frederic Trudeau ha scritto:
> Ive got a problem with a sql query that return 'something', but its seams
> Perl DBI cant figure it out ...
> I was wondering if this could be a FreeTDS problem, since this same function
> is working perfectly
> with MySQL.
>
>
> my $sql = "IF EXISTS ( ";
> $sql .= "SELECT servicekey ";
> $sql .= "FROM ispservice ";
> $sql .= "WHERE ispservice.servicekey = '0001111' ";
> $sql .= "AND ispservice.parentservicekey IS NOT NULL ) ";
>
> $sql .= "BEGIN ";
> $sql .= "FROM ispservice ";
> $sql .= "INNER JOIN ispservice AS t1 ";
> $sql .= "ON t1.servicekey = ispservice.parentservicekey ";
> $sql .= "INNER JOIN ispcustomer ";
> $sql .= "ON ispservice.customerkey = ispcustomer.customerkey ";
> $sql .= "INNER JOIN ispreseller ";
> $sql .= "ON ispservice.resellerkey = ispreseller.resellerkey ";
> $sql .= "WHERE ispservice.servicekey = '0001111' ";
> $sql .= "END ";
>
> $sql .= "ELSE ";
>
> $sql .= "BEGIN ";
> $sql .= "SELECT
> customerid,resellerid,serviceid,servicetype,login,password,name ";
> $sql .= "FROM ispservice ";
> $sql .= "INNER JOIN ispcustomer ";
> $sql .= "ON ispservice.customerkey = ispcustomer.customerkey ";
> $sql .= "INNER JOIN ispreseller ";
> $sql .= "ON ispservice.resellerkey = ispreseller.resellerkey ";
> $sql .= "WHERE ispservice.servicekey = '0001111' ";
> $sql .= "END";
>
> my $sth = $local->prepare($sql);
> $sth->execute || die "$DBI::errstr";
>
> print "Query will return $sth->{NUM_OF_FIELDS} fields.\n";
> print "Field names: @{ $sth->{NAME} }\n";
> print "Result contains ", $sth->rows, " rows.\n";
>
>
> This will print:
>
> Query will return 8 fields.
> Field names: customerid parentserviceid resellerid serviceid servicetype
> login password name
> Result contains 0 rows.
>
> Can someone please explain ?

I think "problem" is 0 rows... It's absolutely normal. sql server (both
sybase and microsoft) return row count after reading all rows..

freddy77





Archive powered by MHonArc 2.6.24.

Top of Page