coolaiddrinker
coolaiddrinker

Reputation: 25

perl sybase : capture stored procedure print and select statement

i have a stored procedure which has a lots of print statement and it results both print statement and a resultset

how do i capture print statement and select statement seperately using perl and (DBI/DBD or CTLib or DBLib)

Upvotes: 0

Views: 1727

Answers (1)

Axeman
Axeman

Reputation: 29854

http://search.cpan.org/~mewp/DBD-Sybase-1.12/Sybase.pm#syb_err_handler_(subroutine_ref) says:

syb_err_handler (subroutine ref)
This attribute is used to set an ad-hoc error handler callback (ie a perl subroutine) that gets called before the normal error handler does it's job. If this subroutine returns 0 then the error is ignored. This is useful for handling PRINT statements in Transact-SQL, for handling messages from the Backup Server, showplan output, dbcc output, etc. [emphasis mine]

And shows the following way to handle this:

$dbh = DBI->connect('dbi:Sybase:server=troll', 'sa', '', 
                { syb_err_handler => \&err_handler });

The other thing that I used to do, knowing that my procs would mainly be called from perl was "select" all printed output with the first column being "Message: " and the second column as the message I wanted to print. I even created a sort of printf-from-the-database function around this.

Upvotes: 1

Related Questions