[freetds] Odd statement execution problem
Will Saxon
WillS at housing.ufl.edu
Mon Jun 23 12:53:55 EDT 2003
Hello,
I have a perl script that is using DBD::Sybase 1.00 and DBI 1.47. I am using FreeTDS 0.61 on a FreeBSD 4.8-STABLE machine with Perl 5.8.0. All of the above are compiled from ports.
This script has one section where the code is similar to this:
unless ($hash{"key"}) {
my $sql = "select value from table where field1 = '$variable' order by field2 desc";
@array = $dbh->selectrow_array($sql);
$hash{"key"} = $array[0];
Occasionally, select statements are failing with an error like this:
Can't call method "selectrow_array" on an undefined value at ./script line ##.
I am not sure why this is happening. I have modified my script to first prepare the statement:
unless ($hash{"key"}) {
my $sql = "select value from table where field1 = '$variable' order by field2 desc";
my $sth = $dbh->prepare($sql);
$sth->execute;
@array = $sth->fetchrow_array;
$hash{"key"} = $array[0];
The weird thing is, $sql is defined directly prior to the statement(s), and I can print it without difficulty. I have tried with an undefined $hash{"key"} and when setting $hash{"key"} to ''. I was also getting a warning when just declaring $hash{"key"} so I stopped doing that.
It does always fail with identical input. I am just not sure what to look for.
-Will
More information about the FreeTDS
mailing list