in reply to DBD:Sybase (how to get output from sp_* procs)

VSarkiss is absolutely right - a lot of output from system stored procedures is sent to the client as "PRINT" messages. These need to be processed in a DBD::Sybase error handler where they will appear with an error code of 0. See the syb_err_handler attribute in the DBD::Sybase documentation for more details.

Michael

  • Comment on Re: DBD:Sybase (how to get output from sp_* procs)

Replies are listed 'Best First'.
Re^2: DBD:Sybase (how to get output from sp_* procs)
by Bone_Scavenger (Novice) on Oct 14, 2004 at 20:31 UTC
    Thanks for the answers. It has me on the right track, but I'm still having some growing pains. I created a new perl script that implements the "showplan" example from DBI::Sybase document. The problem is that I don't seem to get anything in $msg within the error handler. I get values in $err, $sev, $state, $line, $sql & $err_type. $server and $proc are undefined. $msg is blank. I experienced the same behaviour in a "dbcc checkdb" script I was working on earlier. I could post the "showplan" code if needed, but I'm pretty sure is functionally equivalent to the example. Thanks in advance. I hope it's not a RTFM problem. ;-)
      Hmmm - I tried this:
      #!/usr/bin/perl -w use strict; use DBI; my $dbh = DBI->connect('dbi:Sybase:host=somehost;port=4100', 'sa', '', { syb_err_handler => sub { print "@_\n"; } }); $dbh->do("sp_dbcc_recommendations testdb");
      and got
      0 10 1 237 gndb2 sp_dbcc_run_recommendations The checkstorage run corr +esponding to dbid '4', opid '2', reported no faults; therefore, no co +rrective action is necessary. sp_dbcc_recommendations smlive server The checkstorage run corresponding to dbid '4', opid '2', reported no +faults; therefore, no corrective action is necessary.
      Admittedly this is on a 12.5.0.3 server, so you may get different output.

      Try running with DBI->trace(3) - that should give you all of the outputs from the server in the trace file (stderr by default). You can then try to see what the problem is.

      Michael