(db2 数据库)Oracle 中的 DBMS_OUTPUT 或 DB2 的 SQL Server 中的 PRINT 是否有任何等价物,或者我是否需要为这种事情再次跳过我的脑袋?
请提供一些代码。
最佳答案
IBM 的 DB2 版本 9.7
或以后实际上带有DBMS_OUTPUT
模块似乎能够做与 Oracle 版本相同的事情。来自 DB2 documentation , DBMS_OUTPUT
可以从存储过程中调用,例如
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@
这将输出
Hello.
到控制台。请注意,您还需要确保
DBMS_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.
关于sql - db2中是否有像oracle一样的打印语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43222649/