Michael Peppler
Sybase Consulting
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
Sybase on Linux FAQ
Sybperl FAQ
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: "Thomas R dot Ridley" <tridley at questra dot com>
Subject: Help new user with msg and err handlers Perl NT
Date: Dec 17 1997 5:17PM


I am new to both perl and sybperl and am working on NT. A deadly
combination I'm sure.

In an effort to save time an energy I grabbed the binary distribution from
Michael Peppler's home page via the link

Your other option is to use a slightly outdated version of perl (5.001m)
and the NT port of sybperl 2.03. 

"Perl 5.001m + sybperl for NT a full binary distribution, contributed by
Davide Ferina This should be sufficient to get sybperl working on NT. "

I have no problems doing simple queries accessing results using both DBlib
and CTlib.
However I have had 0 success at processing errors or messages in both DBLib
and CTlib using
the examples from the eg\ directory as well as in the Man pages. It seems
as though
the handlers never get executed.

The following code segment produces no output when I change the table
sysusers to the nonexistant fubar.
I am running NT 4.00.1381 (no patches).
SQL Server 11.0.1
Open Client 10.0.4

-----------------------example code segment----------------------------

    use Sybase::CTlib;

    ct_callback(CS_CLIENTMSG_CB, \&msg_cb);
    ct_callback(CS_SERVERMSG_CB, "srv_cb");
    $uid = 'mpeppler'; $pwd = 'my-secret-password'; $srv = 'TROLL';

    $X = Sybase::CTlib->ct_connect($uid, $pwd, $srv);

    #$X->ct_execute("select * from sysusers");
    $X->ct_execute("select * from fubar");

    while(($rc = $X->ct_results($restype)) == CS_SUCCEED) {
        next if($restype == CS_CMD_DONE || $restype == CS_CMD_FAIL ||
                $restype == CS_CMD_SUCCEED);
        if(@names = $X->ct_col_names()) {
             print "@names\n";
        if(@types = $X->ct_col_types()) {
             print "@types\n";
        while(@dat = $X->ct_fetch) {
             print "@dat\n";

    print "End of Results Sets\n" if($rc == CS_END_RESULTS);
    print "Error!\n" if($rc == CS_FAIL);

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

        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;

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

        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;

        printf STDERR "Message String: %s\n", $msg;  CS_SUCCEED;
Tom Ridley -
Questra Consulting
300 Linden Oaks, Rochester, NY 14625
(716) 381-2482 or (800) 785-6359
Extension 213
fax: (716) 381-8098