Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

DBMS_OUTPUT not displaying output while running from sql script

edy12May 29 2017 — edited May 29 2017

Hi Folks,

I am executing an anonymous block by running a sql script and have given dbms_output.put_line statement but even after giving set serveroutput on I am not getting any output on the screen. Below is the code from the sql script and the output.

spool /home/anujk/scripts/execute_dml.log

set serveroutput on;

conn random/random

DECLARE

lv_count NUMBER:=0;

BEGIN

  FOR i IN 1 .. 100000 LOOP

   insert into random_generator values (random_seq.nextval,

                                        DBMS_RANDOM.string('x',10),

                                        DBMS_RANDOM.string('u',10),

                                        DBMS_RANDOM.string('a',10),

                                        DBMS_RANDOM.string('l',10)

                                       );

  END LOOP;

  commit;

  SELECT count(*)

    INTO lv_count

    FROM random.random_generator;

  DBMS_OUTPUT.PUT_LINE('Total number of rows: '||lv_count);

EXCEPTION

WHEN OTHERS THEN

   DBMS_OUTPUT.PUT_LINE('Error: '||SQLERRM);

END;

/

Output -

SQL> @execute_dml.sql

Connected.

PL/SQL procedure successfully completed.

I have 11.2.0.4 installed on oracle linux 6. Any leads will be greatly appreciated.

Thanks

This post has been answered by Gaz in Oz on May 29 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 26 2017
Added on May 29 2017
4 comments
3,805 views