Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: PL/SQL : How do you echo text to screen ?

Re: PL/SQL : How do you echo text to screen ?

From: Tim Smith <tssmith_at_best.com>
Date: 1997/01/02
Message-ID: <32cbcaac.41111635@nntp.best.com>#1/1

On Thu, 02 Jan 1997 08:41:37 -0500, John Hough <q6y_at_ornl.gov> wrote:

>Atif Ahmad Khan wrote:
>> I am new to PL/SQL and need to echo some strings to the screen.
>> Something to the equivalent of
>>
>> echo 'This is a test'; in shell and
>> select 'This is a test' from dual ; in SQL
>>
>> In PL/SQL I can do the following :
>>
>> begin
>> declare product char(7);
>> begin
>> select part_number
>> into product
>> from table1
>> where part_number='123456';

 dbms_output.put_line('This is the product ',product);
>> end;
>> end;
>>
>> This only puts the part_number in the variable product. I would like
>> PL/SQL to display it on the screen somehow.
>>
>> As you can see what I am trying to do is rather simple but my lack
>> of experience in this area is preventing me from achieving it.
>>
>> I would appreciate any helpful hints.
>>
>> Atif Khan
>> aak2_at_ra.msstate.edu
>
>you must issue the command
>
>SQL> set serveroutput on size 100000
>
>from sql before executing the package.

You can read up on the DBMS_OUTPUT package in the Oracle Application Developer's Guide manual, or in Scott Urman's Oracle Press book on Programming in PL/SQL.

The syntax of the PUT_LINE command in your case would be:

dbms_output.put_line('This is the product ' || product);

Note that the concatenation symbol (||) is used to combine strings and numbers, or literal strings and variable strings, etc.

One serious flaw of the DBMS_OUTPUT package is that there is no way of doing an intermediate flush of the output. So if you had code like ...
loop ...
  n := n + 1;
  dbms_output.put_line('We are now processing item ' || n);

you will not see any output until the PL/SQL process finishes, rather than the presumably desired progressive info.

--Tim (tssmith_at_best.com) Received on Thu Jan 02 1997 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US