[freetds] $sth->rows returns nothing ??
Frediano Ziglio
freddyz77 at tin.it
Tue Apr 29 21:02:46 EDT 2003
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
More information about the FreeTDS
mailing list