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: "Milan Mikic" <Milan dot Mikic at gartmore dot com>
Subject: Re: Error handling
Date: Mar 26 1998 9:14AM

No,

not to my knowledge. Here it is:

# @(#)sybutil.pl    1.5  10/18/95
#
# Copyright (c) 1994
#   Michael Peppler and ITF Management SA
#
#   You may copy this under the terms of the GNU General Public License,
#   or the Artistic License, copies of which should have accompanied
#   your Perl kit.

#
# A couple of utility stuff for both Sybase::DBlib and Sybase::Sybperl
#


sub message_handler
{
    my ($db, $message, $state, $severity, $text, $server, $procedure,
$line)
     = @_;

    # Don't display 'informational' messages:
    if ($severity > 10)
    {
     print STDERR ("Sybase message ", $message, ", Severity ", $severity,
            ", state ", $state);
     print STDERR ("\nServer `", $server, "'") if defined ($server);
     print STDERR ("\nProcedure `", $procedure, "'") if defined
($procedure);
     print STDERR ("\nLine ", $line) if defined ($line);
     print STDERR ("\n    ", $text, "\n\n");

# &dbstrcpy returns the command buffer.

     if(defined($db))
     {
         my ($lineno, $cmdbuff) = (1, undef);

         $cmdbuff = &Sybase::DBlib::dbstrcpy($db);

         foreach $row (split (/\n/, $cmdbuff))
         {
          print STDERR (sprintf ("%5d", $lineno ++), "> ", $row, "\n");
         }
     }
    }
    elsif ($message == 0)
    {
     print STDERR ($text, "\n");
    }

    0;
}

sub error_handler {
    my ($db, $severity, $error, $os_error, $error_msg, $os_error_msg)
     = @_;
    # Check the error code to see if we should report this.
    if ($error != SYBESMSG) {
     print STDERR ("Sybase error: ", $error_msg, "\n");
     print STDERR ("OS Error: ", $os_error_msg, "\n") if defined
($os_error_msg);
    }

    INT_CANCEL;
}

&dbmsghandle ("message_handler");
&dberrhandle ("error_handler");

1;




mpeppler@mbay.net on 25/03/98 17:01:22

Please respond to SYBPERL-L@trln.lib.unc.edu

To:   SYBPERL-L@trln.lib.unc.edu
cc:    (bcc: Milan Mikic/GB/GARTMORE)
Subject:  Re: Error handling




Milan Mikic wrote:
>
> Dear All,
>
> Here is a peace of code trying to use example of error/message handling
> supplied with Sybperl 2.03. Does anyone have an idea why it does not
print
> out any error messages, knowing that table dfdfdf does not exist in the
> database.
Your code definitely produces the correct error message here.
I've looked at the 2.03 code and I can't see why it wouldn't
print the error.
Has the sybutil.pl file been modified locally?
Michael
--
Michael Peppler         -||-  Data Migrations Inc.
mpeppler@datamig.com    -||-  http://www.mbay.net/~mpeppler
Int. Sybase User Group  -||-  http://www.isug.com









=============================================================================
Gartmore Investment Management plc is an appointed representative of
Gartmore Investment Ltd (GIL) which is regulated by IMRO and the
Personal Investment Authority. GIL represents only the NatWest and Gartmore
Marketing Group for life assurance, pensions, unit trusts, other regulated
collective investment schemes and investment services.