質問

I have a stored procedure and have put some debug messages like

call dbms_output.put ('calling clean up on <tableName>');

while invoking the procedure, I don't see this line. I am using Aqua data studio for my work. I also did the following while calling the SP

set serveroutput on@ and set serveroutput on

but getting the error like

An unexpected token "on@" was found following "set serveroutput ".  Expected tokens may include:  "="

Can you please suggest as to how to see the statements which I am putting as kind of logs within a SP? I am using "AquaData Studio - 7.0.39"

役に立ちましたか?

解決

set serveroutput is not an SQL statement so it makes no sense to Aqua Data Studio or any other tool, except the IBM DB2 command line processors.

What dbms_output.put does is store the line in an internal array in the dbms_output module. DB2 tools access that array and print its contents to screen after executing your stored procedure.

You can in a way simulate the same behaviour in Aqua Data Studio by creating an exception handler in your stored procedure where you use dbms_output.get_lines to return the line array, then build a cursor from that array using unnest() and return the cursor to the calling application (Aqua).

It might be easier though to just create a logging stored procedure of your own, running an autonomous transaction, that would insert log records into a database table that you can query when necessary.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top