SET SERVEROUTPUT OFF/ON : SERVEROUTPUT « SQL Plus « Oracle PL / SQL






SET SERVEROUTPUT OFF/ON

  
SQL>
SQL>
SQL> SET ECHO ON
SQL> SET SERVEROUTPUT OFF
SQL>
SQL> BEGIN
  2    DBMS_OUTPUT.ENABLE (2000);
  3    DBMS_OUTPUT.PUT_LINE('Three names will be written.');
  4    DBMS_OUTPUT.PUT('J');
  5    DBMS_OUTPUT.NEW_LINE;
  6    DBMS_OUTPUT.PUT('S');
  7    DBMS_OUTPUT.NEW_LINE;
  8    DBMS_OUTPUT.PUT('T');
  9    DBMS_OUTPUT.NEW_LINE;
 10  END;
 11  /

PL/SQL procedure successfully completed.

SQL>
SQL> SET SERVEROUTPUT ON
SQL> DECLARE
  2    throw_away VARCHAR2(50);
  3    names DBMS_OUTPUT.CHARARR;
  4    lines_to_get NUMBER;
  5    inx1 NUMBER;
  6    combined_names VARCHAR2(80);
  7    status NUMBER;
  8  BEGIN
  9    DBMS_OUTPUT.GET_LINE(throw_away, status);
 10
 11    lines_to_get := 3;
 12    DBMS_OUTPUT.GET_LINES(names, lines_to_get);
 13
 14    combined_names := '';
 15    FOR inx1 IN 1 .. lines_to_get LOOP
 16      IF inx1 > 1 THEN
 17        combined_names := combined_names || ' and ';
 18      END IF;
 19
 20      combined_names := combined_names || names(inx1);
 21    END LOOP;
 22    DBMS_OUTPUT.PUT_LINE(combined_names);
 23  END;
 24  /
J and S and T

PL/SQL procedure successfully completed.

SQL>
SQL> --

   
  








Related examples in the same category

1.WORD_WRAPPED option for FORMAT wraps each line to the length specified by the value of the LINESIZE variable
2.TRUNCATED formatting option: each line of the displayed output is truncated exactly at the length specified by the LINESIZE variable.
3.The SET SERVEROUTPUT Command
4.SET SERVEROUTPUT ON SIZE 1000000
5.Make sure SQL*Plus SERVEROUTPUT setting is on