Is there( db2 database) any equivalent of DBMS_OUTPUT in Oracle or PRINT in SQL Server for DB2 or do I need to jump over my head again for this sort of thing?
please provide some code also.
IBM's DB2 version 9.7
or later actually comes with a DBMS_OUTPUT
module which appears to be able to do the same thing as Oracle's version. From the DB2 documentation, DBMS_OUTPUT
can be called from within a stored procedure, e.g.
SET SERVEROUTPUT ON@
CREATE PROCEDURE proc1()
BEGIN
CALL DBMS_OUTPUT.PUT( 'H' );
CALL DBMS_OUTPUT.PUT( 'e' );
CALL DBMS_OUTPUT.PUT( 'l' );
CALL DBMS_OUTPUT.PUT( 'l' );
CALL DBMS_OUTPUT.PUT( 'o' );
CALL DBMS_OUTPUT.PUT( '.' );
CALL DBMS_OUTPUT.NEW_LINE;
END@
CALL proc1@
This would output Hello.
to the console.
Note that you also need to make sure that the output from DBMS_OUTPUT
is being redirected to the standard output:
The procedures in this module allow you to work with the message buffer. Use the command line processor (CLP) command SET SERVEROUTPUT ON to redirect the output to standard output.