[freetds] $sth->rows returns nothing ??
Frederic Trudeau
ftrudeau at cam.org
Tue Apr 29 16:50:33 EDT 2003
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
More information about the FreeTDS
mailing list