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: "Branislav Devrnja" <branislav dot devrnja at db dot com>
Subject: ct_connect in package
Date: Mar 18 2002 6:08AM

Hi ,
can someone give a hint wj=hat could be the problem with this wrapping of CT library cals:

Here is a simple wrapper package:
package CTWrapper1;
require Exporter;

@CTWrapper1::ISA =  qw(Exporter Sybase::CTlib);
@CTWrapper1::EXPORT = qw(new );

$CTWrapper1::VERSION   = 1.00;           #

use Sybase::CTlib;



sub new {
     ($_self, $_user, $_password,$_server,$_database) = @_;
     print "DEBUG $_self $_user $_password $_server\n";
        if ( defined $_database ) { print "$_database \n"; }
    ct_callback(CS_CLIENTMSG_CB, \&msg_cb);
    ct_callback(CS_SERVERMSG_CB, "srv_cb");

        $_dbh = new Sybase::CTlib $_user, $_password, $_server;
#
        if (  $_dbh ) { print "Assigned\n" }

        if ( defined $_database ) {
         $_dbh-> ct_sql("use $_database" )
        }
     return ( $_this = bless ( {}, $_self ));
}

    sub msg_cb {
        my($layer, $origin, $severity, $number, $msg, $osmsg, $dbh) = @_;

        printf STDERR "\nOpen Client Message: (In msg_cb)\n";
        printf STDERR "Message number: LAYER = (%ld) ORIGIN = (%ld) ",
               $layer, $origin;
        printf STDERR "SEVERITY = (%ld) NUMBER = (%ld)\n",
               $severity, $number;
        printf STDERR "Message String: %s\n", $msg;
        if (defined($osmsg)) {
            printf STDERR "Operating System Error: %s\n", $osmsg;
        }
        CS_SUCCEED;
    }

    sub srv_cb {
        my($dbh, $number, $severity, $state, $line, $server,
           $proc, $msg) = @_;


      if ( $number == 5701 ) { return 0; }
    # If $dbh is defined, then you can set or check attributes
    # in the callback, which can be tested in the main body
    # of the code.

        printf STDERR "\nServer message: (In srv_cb)\n";
        printf STDERR "Message number: %ld, Severity %ld, ",
               $number, $severity;
        printf STDERR "State %ld, Line %ld\n", $state, $line;

        if (defined($server)) {
            printf STDERR "Server '%s'\n", $server;
        }

        if (defined($proc)) {
            printf STDERR " Procedure '%s'\n", $proc;
        }
    }

1;

Here is the calling script:

#!/usr/bin/env perl
use   CTWrapper1;

$uid = 'branisd'; $pwd = 'fiftytt'; $srv = 'SYT13'; $db = "master";

my $syb = new CTWrapper1 $uid,$pwd,$srv,$db;
______________________________-

It comes with error: Message_string: ct_cmd_alloc(): user api layer: external error : the connection has been marked dead .
ct_cmd_alloc failed at CTWrapper1.pm line 20

(line 20 is a new method in CTWrapper1.pm)
Any idea what  is wrong in this wrapper package?
Sybperl is 2.12 and Perl 5.004 on Sun Solaris 2.6

Thanks
Branislav





--

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.