Re: Simple PL/SQL output question
From: William Robertson <william_at_williamrobertson.net>
Date: Thu, 10 Mar 2011 00:44:20 +0000
Message-ID: <4D781EE4.8070007_at_williamrobertson.net>
You should not need to re-enable dbms_output once set, unless
something is disabling it or you are somehow invisibly losing
package state. There is nothing special about re-executing a PL/SQL
block that would do this.
SQL*Plus: Release 11.2.0.1.0 Production on Thu Mar 10 00:38:33 2011
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> begin
2 dbms_output.put_line('Some output');
3 end;
4 /
Some output
PL/SQL procedure successfully completed.
SQL> r
1 begin
2 dbms_output.put_line('Some output');
3* end;
Some output
PL/SQL procedure successfully completed.
SQL> /
Some output
PL/SQL procedure successfully completed.
RUN is documented here:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch12037.htm
Date: Thu, 10 Mar 2011 00:44:20 +0000
Message-ID: <4D781EE4.8070007_at_williamrobertson.net>
SQL*Plus: Release 11.2.0.1.0 Production on Thu Mar 10 00:38:33 2011
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> begin
2 dbms_output.put_line('Some output');
3 end;
4 /
Some output
PL/SQL procedure successfully completed.
SQL> r
1 begin
2 dbms_output.put_line('Some output');
3* end;
Some output
PL/SQL procedure successfully completed.
SQL> /
Some output
PL/SQL procedure successfully completed.
RUN is documented here:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch12037.htm
Michael Moore
9 March 2011 17:44
Hi Dennis,Actually I meant show us the entire run like:
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Mar 9 09:40:47 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> set serveroutput onSQL> select * from dual;SP2-0640: Not connectedSQL> connect ops$mmooreEnter password: ********ERROR:ORA-12560: TNS:protocol adapter error
SQL>
Frankly, I'm not familiar with the R command. Perhaps Niall is on the right track.
Regards.Mike
Dennis Williams
9 March 2011 16:29
Thanks Mike. Here is an abbreviated version of my script.SET ECHO OFF
SET VERIFY OFF
SET SERVEROUTPUT ON
DECLARE-- local variables and cursors
BEGIN-- PL/SQL codeDBMS_OUTPUT.PUT('------------------------------------------');
DBMS_OUTPUT.NEW_LINE;
DBMS_OUTPUT.PUT_LINE('QH Source Lot ID = '||LotRec.AppID);
DBMS_OUTPUT.PUT_LINE('QH State = '||LotRec.State);END;
/
Michael Moore
9 March 2011 16:21
It would help to SEE what you did.Mike
Dennis Williams
9 March 2011 15:43
List,I recently wrote a SQL script containing a PL/SQL anonymous block. I used DBMS_OUTPUT to sent results to the screen. This worked fine when I copied and pasted the script into a SQL*Plus session. However, when I just hit "r" to rerun the script, I noticed that it produced no output. Later I passed this to a user who ran it using Toad and got no output. Can anybody tell me what (isn't) going on?The reason I used PL/SQL in this manner is that I needed more logic than SQL itself could provide. In our environment, creating database objects requires a lot of red tape, but we have a read-only account that can be used to run queries or ad-hoc scripts.Thanks,Dennis Williams
-- http://www.freelists.org/webpage/oracle-lReceived on Wed Mar 09 2011 - 18:44:20 CST![]()