Skip to Content.
Sympa Menu

freetds - OK, DBD::Sybase/FreeTDS interaction problem.

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Jaye Mathisen <mrcpu AT internetcds.com>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: OK, DBD::Sybase/FreeTDS interaction problem.
  • Date: Tue, 28 Sep 1999 14:10:32 -0700 (PDT)



I'm running on FreeBSD, using FreeTDS 0.46, and DBD::Sybase-0.19,
DBI-1.12. The server is currently running SQL 6.5, SP 5A.

The dopey question I asked about the rowcount thing turned out to
have a bit more significance than I first thought, because my problem
was that I couldn't detect queries that returned 0 rows.

The following output occurs from the enclosed (short) script. I don't
believe the while() loop should succeed, because the query returns 0 rows.
But I get this error message, rather than just skipping the loop.

Here's the output:

backmaster# ./ex.pl
Unknown property 7
Retrieving data 0
no statement executing at ./ex.pl line 44.

The query is "select * from customer where 1=0". sysusers can
be substituted easily for customer, the point is just to return
0 rows. And you'll have to change the "use plat" to "use
whateverdatabase".

Any ideas on what to look for?

--- short script ---
#!/usr/local/bin/perl

my $q = "select * from customer where 1=0";

use DBI;

if(-f "./PWD")
{
open(PWD, "./PWD") || die "$_/PWD is not readable: $!\n";
while(<PWD>)
{
chop;
s/^\s*//;
next if(/^\#/ || /^\s*$/);
($l, $r) = split(/=/);
$Uid = $r if($l eq UID);
$Pwd = $r if($l eq PWD);
$Srv = $r if($l eq SRV);
}
close(PWD);
}

my $dbh = DBI->connect("dbi:Sybase:server=$Srv", $Uid, $Pwd, {PrintError
=> 0});

die "Unable to connect to $Srv: $DBI::errstr"
unless $dbh;

my $rc;
$rc = $dbh->do("use plat");

my $sth;

$sth = $dbh->prepare("$q") || warn "Problem\n";

if ($sth->execute) {

my $rows = 0;
my @dat;

print "Retrieving data 0\n";
while (@dat = $sth->fetchrow) {
print "Retrieving data\n";
++$rows;

foreach (@dat) {
$_ = '' unless defined($_);
}
print "@dat\n";
}

$sth->finish;
}

$dbh->disconnect;





Archive powered by MHonArc 2.6.24.

Top of Page