Oracle database
set serveroutput on;...(1) DECLARE v_col1 CHAR(20); v_col2 INTEGER; CURSOR c1 IS SELECT col1, col2 FROM t1; BEGIN DBMS_OUTPUT.PUT_LINE('-- BATCH_001 Start --'); OPEN c1; DBMS_OUTPUT.PUT_LINE('-- LOOP Start --'); LOOP FETCH c1 INTO v_col1, v_col2; EXIT WHEN c1%NOTFOUND; DBMS_OUTPUT.PUT('.'); END LOOP; DBMS_OUTPUT.NEW_LINE; ...(2) DBMS_OUTPUT.PUT_LINE('-- LOOP End --'); CLOSE c1; DBMS_OUTPUT.PUT_LINE('-- BATCH_001 End --'); EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('-- SQL Error --'); DBMS_OUTPUT.PUT_LINE('ERROR : ' || SQLERRM ); END; /
Symfoware Server
DO $$ DECLARE v_col1 CHAR(20); v_col2 INTEGER; c1 CURSOR FOR SELECT col1, col2 FROM t1; BEGIN PERFORM DBMS_OUTPUT.SERVEROUTPUT(TRUE); ...(1) PERFORM DBMS_OUTPUT.ENABLE(NULL); ...(1) PERFORM DBMS_OUTPUT.PUT_LINE('-- BATCH_001 Start --'); OPEN c1; PERFORM DBMS_OUTPUT.PUT_LINE('-- LOOP Start --'); LOOP FETCH c1 INTO v_col1, v_col2; EXIT WHEN FOUND = false; PERFORM DBMS_OUTPUT.PUT('.'); END LOOP; PERFORM DBMS_OUTPUT.NEW_LINE(); ...(2) PERFORM DBMS_OUTPUT.PUT_LINE('-- LOOP End --'); CLOSE c1; PERFORM DBMS_OUTPUT.PUT_LINE('-- BATCH_001 End --'); EXCEPTION WHEN OTHERS THEN PERFORM DBMS_OUTPUT.PUT_LINE('-- SQL Error --'); PERFORM DBMS_OUTPUT.PUT_LINE('ERROR : ' || SQLERRM ); END; $$ ;
Use SET statement and specify SERVEROUTPUT ON.
Specify DBMS_SQL.SERVEROUTPUT(TRUE).
Convert using the following procedure:
Check if a SET SERVEROUTPUT statement is specified before the PL/SQL block of a stored procedure.
If a SET SERVEROUTPUT statement is specified, specify DBMS_SQL.SERVEROUTPUT straight after BEGIN of PL/pgSQL. If ON is specified to have messages output to a window, then specify TRUE. If OFF is specified, then specify FALSE.
Specify DBMS_SQL.ENABLE only if SET SERVEROUTPUT is ON. The values to be specified for the argument are as follows:
If SIZE is specified for the SET SERVEROUTPUT statement, specify this size for the argument.
If SIZE is not specified for the SET SERVEROUTPUT statement, then specify 2000 for Oracle10.1g or earlier, NULL for Oracle10.2g or later.
If DBMS_SQL.ENABLE is specified for the PL/SQL block of the stored procedure, specify the same value as that argument.
If there is no argument for packageName.featureName, parenthesis can be omitted.
Even if there is no argument for packageName.featureName, parenthesis cannot be omitted.
Convert using the following procedure:
Locate the places where the keyword "DBMS_OUTPUT.NEW_LINE" is used in the stored procedure.
If there is no parenthesis after packageName.featureName, add the parenthesis.