Re: PL/SQL and output

From: Hakan Eren <heren_at_erpdbo.com>
Date: 1998/03/23
Message-ID: <3516F1AA.30135EC8_at_erpdbo.com>#1/1


Hi Kevin,

I did not understand why you don't want to use DBMS_OUTPUT.PUT_LINE. It works perfect for me. In case of you may want to use it, you can try the following code. I intended to read some fields from a table and insert them to another table. Please Notice DBMS_OUTPUT.ENABLE, you may increase it if you need bigger output files. I guess that's solution for you. (Just guess, not sure)

DECLARE
  CURSOR c1 IS SELECT FieldNames FROM TableName;   temp_1 TableName.FieldName%TYPE;
  temp_2 TableName.FieldName%TYPE;
BEGIN
  DBMS_OUTPUT.ENABLE(1000000);
  OPEN c1;
  LOOP
    FETCH c1 INTO temp_1, temp_2...;
    EXIT WHEN c1%NOTFOUND;
    INSERT INTO

      TableName(FieldNames...)
      VALUES(Values....);

    DBMS_OUTPUT.PUTLINE(TO_CHAR(temp_1) || TO_CHAR(temp_2)); -- Here I assume these are numbers. In case of varchar2 no need to convert

  END LOOP;
  CLOSE c1;
END; Hakan Eren

neeren wrote:

> Kevin Bass wrote:
> >
> > I have attempted to print output from a PL/SQL program into a file but
> > received no results. Are there any other ways to print information (data)
> > into a file without using DBMS_OUTPUT.PUT_LINE or DBMS_OUTPUT.PUT? If so,
> > please send sample code.
> >
> > Kevin
>
> In SQLPLUS do the following command
> SET linesize 240 (or the length of the columns you are selecting)
>
> set spool <filename>.lst
> execute select
> set spool off;
Received on Mon Mar 23 1998 - 00:00:00 CET

Original text of this message