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?


In reply to two connections to the same database with DBD::Sybase by busunsl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.