Skip to Content.
Sympa Menu

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

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Frederic Trudeau" <ftrudeau AT cam.org>
  • To: <freetds AT lists.ibiblio.org>
  • Subject: [freetds] $sth->rows returns nothing ??
  • Date: Tue, 29 Apr 2003 15:50:33 -0400


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 ?

---------------------------------------------------
Frederic Trudeau
PHP Coder, Colocation, Development
ftrudeau AT cam.org
514.529.3000 ext. 246





Archive powered by MHonArc 2.6.24.

Top of Page