perlquestion
busunsl
Hi folks!<p>
I have the following problem:<p>
I want to write a simple script that compares the contents of two tables for my <a href=http://www.widd.de/bernd/cookbook/sybase_dba_perl_cookbook.html>Sybase DBA Perl Cookbook</a>.<p>
The script iterates over all rows from one table, select the corresponding row from the other table and print the primary keys if the rows are different.<br>
So nothing much.<p>
But if I try to execute a statement with placeholders while another statement has results pending, the Sybase Client Library pukes:<p>
<code>
ct_param() failed! at /tmp/xx.pl line 33.
DBD::Sybase::st execute failed: OpenClient message: LAYER = (1) ORIGIN = (1) SEVERITY = (1) NUMBER = (16)
Message String: ct_param(): user api layer: external error:
This routine cannot be called while results are pending for a command that has been sent to the server.
DBD::Sybase::st execute failed: OpenClient message: LAYER = (1) ORIGIN = (1) SEVERITY = (1) NUMBER = (16)
Message String: ct_param(): user api layer: external error:
This routine cannot be called while results are pending for a command that has been sent to the server.</code>
The script:
<code>
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
my $dbh1 = DBI->connect("dbi:Sybase:server=server1;database=database1", 'user1', 'passwd1');
my $dbh2 = DBI->connect("dbi:Sybase:server=server2;database=database2", 'user2', 'passwd2');
my $sth1 = $dbh1->prepare("select * from table1");
my $sth2 = $dbh2->prepare("select * from table2 where primkey = ?");
$sth1->execute;
#---- iterate through table1, check in table2
while (my @row1 = $sth1->fetchrow_array) {
$sth2->execute($row1[0]); # this is line 33
my @row2 = $sth2->fetchrow_array;
}
</code><p>
Versions:<p>
<pre>
Perl: 5.8.0 Linux
DBI: 1.30
DBD::Sybase: 0.95
Perl: 5.6.1 NT
DBI: 1.30
DBD::Sybase: 0.91
</pre>
Anyone came across this before?<p>
Is this a serious limitation in the Sybase Client Library?<p>
The workaround would be to use a <code>selectrow</code> in each iteration, which would be dead slow.
<p>
Would a <code>bind_param</code> help?