Good Afternoon “cetzhbo”,
to turn the DBMS_OUTPUT output on, you should, in a PL/SQL block, or script running anonymous blocks etc, execute something like the following in your code:
dbms_output.enable(size);
Where ‘size’ is the number of bytes you want to make the output buffer. Up to Oracle 10G (if I remember correctly) the maximum size was 1,000,000 bytes, however, from 10G onwards, unlimited can be specified by not supplying a size, or supplying NULL instead, as in these two examples:
dbms_output.enable;
dbms_output.enable(NULL);
If you do this, and the database version is less than 10g, then NULL has the effect of specifying 20,000, otherwise it means unlimited.
In a script, that you would execute with F5 (Run as a script) in the editor, you should be able to :
set serveroutput on size unlimited;
As the first (or nearly first) executable SQL statement. If your script does this, and then goes on to execute DBMS_OUTPUT.PUT_XXXXX commands, then there is no need to call DBMS_OUTPUT.ENABLE within the PL/SQL code you are executing as the set server output on … command does exactly that, for you.
If, on the other hand, you are writing a procedure/function/package, then you will need the call to DBMS_OUTPUT.ENABLE.
Examples:
This can be executed by a script, run with F5, and the output will appear in the ‘script output’ and the ‘dbms_output’ panes at the bottom of the screen where any other PL/SQL results will also be shown - regardless of whether or not the ‘dbms_output’ pane is showing ‘disabled’ or not.
set serveroutput on size unlimited;
begin
dbms_output.put_Line(‘Hello world!’);
end;
/
Alternatively, this will work too, again, you can execute it with F5:
begin
DBMS_OUTPUT.ENABLE(NULL);
dbms_output.put_Line(‘Hello again world!’);
end;
/
Again, the output will show up in both panes, as above.
If you are unable to see the ‘dbms_output’ pane, at the bottom of the screen, then simply right click on any tab (on the actual tab in the header bar that is) and check the option for DBMS_OUTPUT on the pop-up that appears.
HTH