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: David dot Whitsed at hr-m dot b-m dot defence dot gov dot au
Subject: Re: Re[2]: Open Client needed?
Date: Jul 8 1999 12:24AM

You need to install a callback procedure for server messages and
catch messages with severity = 10 and message number = 0

eg.

    # install ct-lib callbacks
    ct_callback(CS_SERVERMSG_CB, \&server_cb);

sub server_cb
{
    my($cmd, $number, $severity, $state, $line, $server, $proc, $msg) =
@ARG;

    # catch output from sql print statements
    if($number == 0 && $severity == 10){
        print STDERR "$msg\n";
    }

    # don't worry about info messages (severity 10)
    return $DB_OK if($severity < 11);

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

    if (defined($cmd)) {
     printf STDERR "cmd: %s\n", $cmd;
    }

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

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

    printf STDERR "Message String: %s\n", $msg;

    # set these global variables so that other routines
    #can tell that an error has occurred.

    $svr_msg = $number;
    $svr_severity = $severity;

    # callbacks MUST return CS_SUCCEED
    CS_SUCCEED;
}