如何通过 DbVisualizer 等 GUI 工具在 DB2 调用中创建匿名块
How to create anonymous block in DB2 call via GUI tool like DbVisualizer
代码:
SET SERVEROUTPUT ON;
declare count_t integer : = 0;
BEGIN
CALL DBMS_OUTPUT.PUT_LINE ( 'Hello' );
CALL DBMS_OUTPUT.PUT_LINE ( 'count_t-' || count_t );
END;
无法在 DB2 中执行。
错误:
[Code: -104, SQL State: 42601] An unexpected token "SERVEROUTPUT" was found following "SET ". Expected tokens may include: "SSA".. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.28.11
还有
[Code: -104, SQL State: 42601] An unexpected token "declare count_t integer" was found following "BEGIN-OF-STATEMENT". Expected tokens may include: "<select>".. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.28.11
您必须对 运行 复合语句使用不同的语句定界符/终止符。
每个客户端工具都有自己的设置方法。
数据库可视化工具:
Tools\Tool Properties\SQL Commander\Statement Delimiters:
SQL Statement Delimiter:
SQL Statement Delimiter 1: @
SQL Statement Delimiter 2: @
Only in DbVisualizer DbVisualizer Pro edition.
This feature is only available in the DbVisualizer Pro edition.
BEGIN
declare count_t integer default 0;
CALL DBMS_OUTPUT.PUT_LINE ( 'Hello' );
CALL DBMS_OUTPUT.PUT_LINE ( 'count_t-' || count_t );
END
@
代码:
SET SERVEROUTPUT ON;
declare count_t integer : = 0;
BEGIN
CALL DBMS_OUTPUT.PUT_LINE ( 'Hello' );
CALL DBMS_OUTPUT.PUT_LINE ( 'count_t-' || count_t );
END;
无法在 DB2 中执行。 错误:
[Code: -104, SQL State: 42601] An unexpected token "SERVEROUTPUT" was found following "SET ". Expected tokens may include: "SSA".. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.28.11
还有
[Code: -104, SQL State: 42601] An unexpected token "declare count_t integer" was found following "BEGIN-OF-STATEMENT". Expected tokens may include: "<select>".. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.28.11
您必须对 运行 复合语句使用不同的语句定界符/终止符。
每个客户端工具都有自己的设置方法。
数据库可视化工具:
Tools\Tool Properties\SQL Commander\Statement Delimiters:
SQL Statement Delimiter:
SQL Statement Delimiter 1: @
SQL Statement Delimiter 2: @
Only in DbVisualizer DbVisualizer Pro edition.
This feature is only available in the DbVisualizer Pro edition.
BEGIN
declare count_t integer default 0;
CALL DBMS_OUTPUT.PUT_LINE ( 'Hello' );
CALL DBMS_OUTPUT.PUT_LINE ( 'count_t-' || count_t );
END
@