http://www.perlmonks.org?node_id=218763

busunsl has asked for the wisdom of the Perl Monks concerning the following question:

Hi folks!

I have the following problem:

I want to write a simple script that compares the contents of two tables for my Sybase DBA Perl Cookbook.

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.
So nothing much.

But if I try to execute a statement with placeholders while another statement has results pending, the Sybase Client Library pukes:

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 comm +and 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 comm +and that has been sent to the server.
The script:
#!/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 li +ne 33 my @row2 = $sth2->fetchrow_array; }

Versions:

Perl:        5.8.0 Linux
DBI:         1.30
DBD::Sybase: 0.95

Perl:        5.6.1 NT
DBI:         1.30
DBD::Sybase: 0.91
Anyone came across this before?

Is this a serious limitation in the Sybase Client Library?

The workaround would be to use a selectrow in each iteration, which would be dead slow.

Would a bind_param help?