in reply to Error Handeling in Sybase::Dblib

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