PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: "Delegal, Darin" <ddelegal at citistreetonline dot com>
Subject: RE: Very Odd Problem
Date: Mar 29 2004 7:23PM

According to the CTlib reference guide, a server callback routine must retrun CS_SUCCEED. Client message routines must return either CS_SUCCEED or CS_FAIL. Since you're not specifying a return value from the functions, perl is using the last result value within the function (most likely the return value from the print statements) which is confusing the API.

If you simply add "return &CS_SUCCEED;" at the end of each callback routine, things will work as intended.

Darin Delegal


-----Original Message-----
From: owner-sybperl-l@peppler.org [mailto:owner-sybperl-l@peppler.org]On
Behalf Of r huber
Sent: Monday, March 29, 2004 1:58 PM
To: sybperl-l@peppler.org
Subject: Very Odd Problem


The following code appears to work as expected:

     1  #!/usr/local/bin/perl
     2
     3  # Subroutines
     4
     5  #
     6  sub msg_cb {
     7      my($layer, $orgin, $severity, $number,
$msg,  $omsg, $dbh) = @_;
     8
     9      print "msg_cb \@_ ==>$layer, $orgin,
$severity, $number, $msg,  $omsg, $dbh<==\n";
    10
    11      print "===> sub msg_cb called\n";
    12  }
    13  #
    14  sub srv_cb{
    15      my($dbh, $number, $severity, $state,
$line, $server, $proc, $msg) = @_;
    16
    17      print "srv_cb \@_ ==>$dbh, $number,
$severity, $state, $line, $server, $proc, $msg<==\n";
    18
    19      if( $number != 5701 ){
    20         print "hello world\n";
    21         printf "error message is 0x%x\n",
$number;
    22         }
    23      else{
    24         print "goodby world\n";
    25         printf "error message is 0x%x\n",
$number;
    26         }
    27     }
    28
    29  # Main
    30
    31  use Sybase::CTlib;
    32
    33  ct_callback(CS_CLIENTMSG_CB, \&msg_cb);
    34  ct_callback(CS_SERVERMSG_CB, "srv_cb");
    35
    36
    37  $dbh= Sybase::CTlib->ct_connect( "user",
"passwd", "server" );
    38
    39  print "\n\$dbh = $dbh\n";
    40
    41  @dat = $dbh->ct_sql("use database");
    42         if($dbh->{'RC'} == CS_FAIL) {
    43             die "Can not access database\n";
    44         }


If lines 23 thru 26 are commented out the code fails
in that the connect does not return a database handle.

Any ideas as to what is going on.

Thanks,
Robert

__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html