dbTalk Databases Forums  

put_line: any way to have nonbuffered output?

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss put_line: any way to have nonbuffered output? in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
geos
 
Posts: n/a

Default put_line: any way to have nonbuffered output? - 10-05-2011 , 03:33 AM






put_line places data into buffer. this data is displayed as soon as
pl/sql code is finished and control returns to invoking environment (eg.
sqlplus). in some sense the display via put_line is delayed compared to
the moment of data availability.

is there any other way in oracle, built-in or via third party
methods/packages, that controls display from pl/sql code without using
the "display buffer", ie. immediately after the data is available?

I would greatly appreciate your help and explanations.
thank you,
geos

--
FUT to: comp.databases.oracle.misc

Reply With Quote
  #2  
Old   
Mladen Gogala
 
Posts: n/a

Default Re: put_line: any way to have nonbuffered output? - 10-05-2011 , 01:06 PM






On Wed, 05 Oct 2011 10:33:57 +0200, geos wrote:

Quote:
put_line places data into buffer. this data is displayed as soon as
pl/sql code is finished and control returns to invoking environment (eg.
sqlplus). in some sense the display via put_line is delayed compared to
the moment of data availability.

is there any other way in oracle, built-in or via third party
methods/packages, that controls display from pl/sql code without using
the "display buffer", ie. immediately after the data is available?

I would greatly appreciate your help and explanations. thank you,
geos
If you check the file $ORACLE_HOME/rdbms/admin/dbmsotpt.sql, you will see
that it begins like this:

CREATE OR REPLACE TYPE dbmsoutput_linesarray IS
VARRAY(2147483647) OF VARCHAR2(32767);
/

That means that Oracle will place lines in the variable of the type
dbmsoutput_linesarray during the execution. The line buffer is private to
the package body, so only member functions can access it.

This is where the lines from DBMS_OUTPUT.PUT_LINE get placed when the
"PUT_LINE" procedure is executed. After the execution ends, sqlplus
executes dbms_output.get_lines to retrieve lines and displays them on the
standard output. As Oracle session can only execute a single SQL or PL/
SQL
at any given time, you can't have something that would asynchronously
check on the state of the array. Now an illustration:

SQL> set serveroutput on
SQL> select count(*) from emp;

COUNT(*)
----------
14

SQL> select * from table(dbms_xplan.display_cursor);

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
SQL_ID 9babjv8yq8ru3, child number 0

BEGIN DBMS_OUTPUT.GET_LINES(:LINES, :NUMLINES); END;

NOTE: cannot fetch plan for SQL_ID: 9babjv8yq8ru3, CHILD_NUMBER: 0
Please verify value of SQL_ID and CHILD_NUMBER;
It could also be that the plan is no longer in cursor cache (check v
$sql_p
lan)

The dbms_xplan.display_cursor displayed dbms_output.get_lines because of
the serveroutput sqlplus setting, which instructed sqlplus to execute
dbms_output.get_lines after the execution and has therefore changed the
last cursor. If I stop the server output, the result is something
completely different, and I don't mean John Cleese in a bikini:

SQL> set serveroutput off
SQL> select count(*) from emp;

COUNT(*)
----------
14

SQL> select * from table(dbms_xplan.display_cursor);

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
SQL_ID g59vz2u4cu404, child number 0
-------------------------------------
select count(*) from emp

Plan hash value: 2937609675

-------------------------------------------------------------------
Quote:
Id | Operation | Name | Rows | Cost (%CPU)| Time |
-------------------------------------------------------------------
0 | SELECT STATEMENT | | | 1 (100)| |
1 | SORT AGGREGATE | | 1 | | |
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Quote:
2 | INDEX FULL SCAN| PK_EMP | 14 | 1 (0)| 00:00:01 |
-------------------------------------------------------------------


14 rows selected.

SQL>




8 rows selected.


So, the answer to your question is no. You cannot asynchronously check
the content of the line buffer because Oracle session can execute only a
single SQL (or PL/SQL) unit at any given time. If you describe V$SESSION,
you will see only the entries describing the current and the previous
SQL.
That wouldn't be possible, if there was a possibility to have 2 or more
simultaneous statements that could be executed by the same session.





--
http://mgogala.byethost5.com

Reply With Quote
  #3  
Old   
geos
 
Posts: n/a

Default Re: put_line: any way to have nonbuffered output? - 10-05-2011 , 01:40 PM



Mladen Gogala wrote:
Quote:
So, the answer to your question is no. You cannot asynchronously check
the content of the line buffer because Oracle session can execute only a
single SQL (or PL/SQL) unit at any given time. If you describe V$SESSION,
you will see only the entries describing the current and the previous
SQL.
That wouldn't be possible, if there was a possibility to have 2 or more
simultaneous statements that could be executed by the same session.
thanks for this expanded answer!

cheers,
geos

Reply With Quote
  #4  
Old   
Gerard H. Pille
 
Posts: n/a

Default Re: put_line: any way to have nonbuffered output? - 10-05-2011 , 02:33 PM



geos wrote:
Quote:
put_line places data into buffer. this data is displayed as soon as pl/sql code is finished and
control returns to invoking environment (eg. sqlplus). in some sense the display via put_line is
delayed compared to the moment of data availability.

is there any other way in oracle, built-in or via third party methods/packages, that controls
display from pl/sql code without using the "display buffer", ie. immediately after the data is
available?

I would greatly appreciate your help and explanations.
thank you,
geos


There used to be something called dbms_pipe.

Reply With Quote
  #5  
Old   
geos
 
Posts: n/a

Default Re: put_line: any way to have nonbuffered output? - 10-05-2011 , 03:22 PM



Gerard H. Pille wrote:
Quote:
There used to be something called dbms_pipe.
yes, but his is what I wanted to do (modified example from
Feuerstein/Pribyl book, page 111: http://tinyurl.com/6funmrc)

session 1: http://geos2005.republika.pl/sesja1.sql
session 2: http://geos2005.republika.pl/sesja2.sql

pl/sql (2) can "communicate" with pl/sql (1) but the latter one can't
display until it is finished.

thanks,
geos

Reply With Quote
  #6  
Old   
Gerard H. Pille
 
Posts: n/a

Default Re: put_line: any way to have nonbuffered output? - 10-05-2011 , 05:37 PM



geos wrote:
Quote:
Gerard H. Pille wrote:
There used to be something called dbms_pipe.

yes, but his is what I wanted to do (modified example from Feuerstein/Pribyl book, page 111:
http://tinyurl.com/6funmrc)

session 1: http://geos2005.republika.pl/sesja1.sql
session 2: http://geos2005.republika.pl/sesja2.sql

pl/sql (2) can "communicate" with pl/sql (1) but the latter one can't display until it is finished.

thanks,
geos

The reading side of dbms_pipe should be handled by a PRO*C or Java program, and spool output
immediately.

Reply With Quote
  #7  
Old   
geos
 
Posts: n/a

Default Re: put_line: any way to have nonbuffered output? - 10-06-2011 , 01:26 AM



Gerard H. Pille wrote:
Quote:
session 1: http://geos2005.republika.pl/sesja1.sql
session 2: http://geos2005.republika.pl/sesja2.sql

pl/sql (2) can "communicate" with pl/sql (1) but the latter one can't
display until it is finished.

The reading side of dbms_pipe should be handled by a PRO*C or Java
program, and spool output immediately.
do I understand right, that Pro*C means running the compiled output as
system program, not "inside" sqlplus as it is with anonymous block, and
to display the messages appropriate Pro*C "display function" should be
used?

thank you,
geos

Reply With Quote
  #8  
Old   
Mark D Powell
 
Posts: n/a

Default Re: put_line: any way to have nonbuffered output? - 10-06-2011 , 09:06 AM



On Oct 6, 2:26*am, geos <g... (AT) nowhere (DOT) invalid> wrote:
Quote:
Gerard H. Pille wrote:
session 1:http://geos2005.republika.pl/sesja1.sql
session 2:http://geos2005.republika.pl/sesja2.sql

pl/sql (2) can "communicate" with pl/sql (1) but the latter one can't
display until it is finished.

The reading side of dbms_pipe should be handled by a PRO*C or Java
program, and spool output immediately.

do I understand right, that Pro*C means running the compiled output as
system program, not "inside" sqlplus as it is with anonymous block, and
to display the messages appropriate Pro*C "display function" should be
used?

thank you,
geos
The dbms_pipe package, which should generally not be used in a RAC
environment, is a mean to pass data between two Oracle sessions. The
first session packs the data into the pipe and the second session
unpacks the data from the pipe. Depending on your version you can
find information on this Oracle provided package in the PL/SQL
Packages and Types manual or Supplied PL/SQL Packages and Types
Reference.

If you used dbms_pipe instead of dbms_output a pro*C program could
unpack the pipe concurrently to the first session filling the pipe and
write out the output or insert it into a table independently of the
first session transaction.

An alternate approach that work in a RAC environment would be to
substitute a logging routine for dbms_output where the logging routine
was written as an anonymous transaction; however, you would have to
read the results from a separate session so neither of these
approaches may be of any use if what you want is for the current
session to see the dbms_output as it is generated on the current
session screen.

HTH -- Mark D Powell --

Reply With Quote
  #9  
Old   
Gerard H. Pille
 
Posts: n/a

Default Re: put_line: any way to have nonbuffered output? - 10-06-2011 , 03:35 PM



Mark D Powell wrote:
Quote:
On Oct 6, 2:26 am, geos<g... (AT) nowhere (DOT) invalid> wrote:
Gerard H. Pille wrote:
session 1:http://geos2005.republika.pl/sesja1.sql
session 2:http://geos2005.republika.pl/sesja2.sql

pl/sql (2) can "communicate" with pl/sql (1) but the latter one can't
display until it is finished.

The reading side of dbms_pipe should be handled by a PRO*C or Java
program, and spool output immediately.

do I understand right, that Pro*C means running the compiled output as
system program, not "inside" sqlplus as it is with anonymous block, and
to display the messages appropriate Pro*C "display function" should be
used?

thank you,
geos

The dbms_pipe package, which should generally not be used in a RAC
environment, is a mean to pass data between two Oracle sessions. The
first session packs the data into the pipe and the second session
unpacks the data from the pipe. Depending on your version you can
find information on this Oracle provided package in the PL/SQL
Packages and Types manual or Supplied PL/SQL Packages and Types
Reference.

If you used dbms_pipe instead of dbms_output a pro*C program could
unpack the pipe concurrently to the first session filling the pipe and
write out the output or insert it into a table independently of the
first session transaction.

An alternate approach that work in a RAC environment would be to
substitute a logging routine for dbms_output where the logging routine
was written as an anonymous transaction; however, you would have to
read the results from a separate session so neither of these
approaches may be of any use if what you want is for the current
session to see the dbms_output as it is generated on the current
session screen.

HTH -- Mark D Powell --


"anonymous transaction" being "autonomous transaction" ?

Reply With Quote
  #10  
Old   
Mark D Powell
 
Posts: n/a

Default Re: put_line: any way to have nonbuffered output? - 10-07-2011 , 08:32 AM



On Oct 6, 4:35*pm, "Gerard H. Pille" <g... (AT) skynet (DOT) be> wrote:
Quote:
Mark D Powell wrote:
On Oct 6, 2:26 am, geos<g... (AT) nowhere (DOT) invalid> *wrote:
Gerard H. Pille wrote:
session 1:http://geos2005.republika.pl/sesja1.sql
session 2:http://geos2005.republika.pl/sesja2.sql

pl/sql (2) can "communicate" with pl/sql (1) but the latter one can't
display until it is finished.

The reading side of dbms_pipe should be handled by a PRO*C or Java
program, and spool output immediately.

do I understand right, that Pro*C means running the compiled output as
system program, not "inside" sqlplus as it is with anonymous block, and
to display the messages appropriate Pro*C "display function" should be
used?

thank you,
geos

The dbms_pipe package, which should generally not be used in a RAC
environment, is a mean to pass data between two Oracle sessions. *The
first session packs the data into the pipe and the second session
unpacks the data from the pipe. *Depending on your version you can
find information on this Oracle provided package in the PL/SQL
Packages and Types manual or Supplied PL/SQL Packages and Types
Reference.

If you used dbms_pipe instead of dbms_output a pro*C program could
unpack the pipe concurrently to the first session filling the pipe and
write out the output or insert it into a table independently of the
first session transaction.

An alternate approach that work in a RAC environment would be to
substitute a logging routine for dbms_output where the logging routine
was written as an anonymous transaction; however, you would have to
read the results from a separate session so neither of these
approaches may be of any use if what you want is for the current
session to see the dbms_output as it is generated on the current
session screen.

HTH -- Mark D Powell --

"anonymous transaction" being "autonomous transaction" ?- Hide quoted text -

- Show quoted text -
Yes. http://download.oracle.com/docs/cd/B....htm#sthref307

Thanks. I wonder how long I have been doing that.

HTH -- Mark D Powell --

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.