Error messages are printed from the "message" handler in DBlib. For Sybase::DBlib you create a subroutine that will handle any messages, and then install it with dbmsghandle(\&my_handler_sub).

For example:

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 ", $severit +y, ", state ", $state); print STDERR ("\nServer `", $server, "'") if defined ($server); print STDERR ("\nProcedure `", $procedure, "'") if defined ($proce +dure); 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); my $row; $cmdbuff = &Sybase::DBlib::dbstrcpy($db); foreach $row (split (/\n/, $cmdbuff)) { print STDERR (sprintf ("%5d", $lineno ++), "> ", $row, "\n"); } } } elsif ($message == 0) { print STDERR ($text, "\n"); } return 0; } dbmsghandle(\&message_handler);
Now when any error (or PRINT statement in SQL) is executed/sent from the server it will be sent to your message handler, and you can control how and where the messages get printed.

See also the Sybase docs for OpenClient at http://sybooks.sybase.com/onlinebooks/group-sd/sdg1251e/dblib, and of course the Sybase::DBlib documentation.

Michael


In reply to Re: Error Handeling in Sybase::Dblib by mpeppler
in thread Error Handeling in Sybase::Dblib by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.