Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

LOOP FOR AND DYNAMIC FROM SOURCE, UTL_FILE.PUT_LINE problem

Krzysztof PioMay 8 2017 — edited May 8 2017

DECLARE

table_name_variable     VARCHAR2(200)   := 'table_1';

zawartosc                      LONG                    := 'r.' || COLUMN1_NAME || '' '' || 'r.' || COLUMN2_NAME;

....

FOR r IN (SELECT * FROM table_1) -- 1. I want to use here my TABLE_NAME_VARIABLE instead of pure name of table (table_1).

  LOOP    

    UTL_FILE.PUT_LINE(

      file_name,

      r.COLUMN1_NAME || ' ' || r.COLUMN2_NAME -- 2. In place of this i would like to use variable called COMMAND := 'r.COLUMN1 || '' '' || r.COLUMN2'

    );

  END LOOP;

Second point is important for me becouse i want to dynamicly generate the list of columns to write from table_1.

Finally i want to create a procedure with 3 parameters:

1. direction where i want to save my data

2. name of my data file which i want to create

3. TABLE_NAME which i want to save

The most important is question nr 2. Can I do sth like this?

This post has been answered by BluShadow on May 8 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 5 2017
Added on May 8 2017
5 comments
918 views