Re: HELP: Output from within Stored Procedure

From: Thomas J. Kyte <tkyte_at_us.oracle.com>
Date: 1996/06/09
Message-ID: <31bb33ce.10098140_at_dcsun4>#1/1


On 6 Jun 96 20:31:23 GMT, jba_at_dk-online.dk (Joergen Bach) wrote:

>Hello,
>
>How is output received/handled in PRO*C programs??
>
>It would be nice if such output can be printed on stdout.
>
>Best regards, Joergen Bach, Lyngby, Denmark

The pro*c program gets back the lines via the dbms_output.get_line or dbms_output.get_lines procedure calls. You must call dbms_output.enable in your pro*c code as well.

For example:

void f()
{
EXEC SQL BEGIN DECLARE SECTION;

	VARCHAR		l[255];
	int		status;

...
EXEC SQL END DECLARE SECTION;
....

        EXEC SQL EXECUTE BEGIN DBMS_OUTPUT.ENABLE; END; END-EXEC; ....

	EXEC SQL ........
	EXEC SQL ........

	for(;;) 
	{
		EXEC SQL EXECUTE BEGIN DBMS_OUTPUT.GET_LINE(:l,:status); END;
		END-EXEC;
		if ( status == 1 ) break;
		printf( "*.*s\n", l.len, l.len, l.arr );
	}

.....

>
>In message <31b0745e.3494354_at_dcsun4> - tkyte_at_us.oracle.com (Thomas J.
>Kyte)Sat, 01 Jun 1996 16:52:51 GMT writes:
>:>
>:>On 1 Jun 1996 15:49:39 GMT, bcopping_at_cpcug.org wrote:
>:>
>:>>In <4motps$59r_at_newsbf02.news.aol.com>, ahoff54565_at_aol.com (AHoff54565) writes:
>:>>>Hello,
>:>>>
>:>>>There is a system package called DBMS_OUTPUT.PUT_LINE which outputs data
>:>>>from within a PL/SQL routine. You need to SET SERVEROUTPUT ON in your
>:>>>SQL*PLUS session in order for this to work.
>:>>>
>:>>>Example:
>:>>>
>:>>>BEGIN
>:>>>
>:>>>DBMS_OUTPUT.PUT_LINE('hello world'); <---output to screen
>:>>>
>:>>>END;
>:>>>
>:>>>This package can display text and variables. Also, in SQL*PLUS routines
>:>>>you can spool output using the spool <file name> command before the select
>:>>>statement. Good Luck.
>:>>
>:>>Is it possible to include the session command (serveroutput on) in the PL/SQL
>:>>routine so the user doesn't have to issue it each time?
>:>>Thanks,
>:>>Bruce Copping
>:>
>:>No in pl/sql. set serveroutput on is a SQL*Plus command, not pl/sql
>:>or sql.
>:>
>:>You can put the set serveroutput on in your glogin.sql or login.sql
>:>files. These files are used by sql*plus to set defaults upon login.
>:>
>:>
>
>
>
>

Thomas Kyte
Oracle Government
tkyte_at_us.oracle.com                          

http://govt.us.oracle.com -- Check out our web site! Brand new, uses Oracle Web Server and Database


statements and opinions are mine and do not necessarily reflect the opinions of Oracle Corporation Received on Sun Jun 09 1996 - 00:00:00 CEST

Original text of this message