Code :
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;
Unable to execute in DB2. Error :
[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
And also
[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
CodePudding user response:
You must use different Statement Delimiter / Terminator to run compound statements.
Every client tool has its own methods of setting it.
Dbvisualizer:
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
@