Jason,
Have you tried it? I've never been able to catch print statements from stored procs with an error handler ( DBD::Sybase Version 1.61 and Sybase 12.5.x).

I tried using your error handler on a tempdb table I created

!/usr/local/bin/perl use strict; use DBI; my $dbh = DBI->connect("dbi:Sybase:server=xxx", "u", "p", { PrintError => 0, syb_err_handler => \&syb_error_handler } ); $dbh->do( "use tempdb" ); my $sql = "exec sp_rename derby, derby1"; $dbh->do( $sql ); sub syb_err_handler { my ($err, $sev, $state, $line, $server, $proc, $msg, $sql, $err_ty +pe) = @_; my $ERROR = 1; my $WARNING = 0; my $return_code = $ERROR; if ( ($err == 131) && ($sev == 5) ) { ## Connection attempt failed return $ERROR; } elsif ( ($err == 0) && ($sev == 10) && ($state == 1) ) { if ( $msg =~ m/Active traceflags:/i ) { process_dbcc_list($msg); $return_code = $WARNING; } else { unless ( $msg =~ m/^\s+$/ ) { chomp $msg; print $msg . "\n"; } } $return_code = $WARNING; } elsif ( ($err == 3) && ($sev == 5) ) { print "err: $msg\n"; $return_code = $ERROR; } return ($return_code); }

Just didn't work. The print statement was not caught by the error handler and was outputted to STDERR.

-derby

In reply to Re^4: DBI, sp_rename, and STDERR by derby
in thread DBI, sp_rename, and STDERR by notwitch

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.