Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2003
    Location
    MN
    Posts
    10

    Unanswered: TEXT_IO ? Build tbl columns dynamically

    I have a form that exports tbl data.
    The tbl columns have changed over time, so I'd like to build the columns that should be exported on the fly. I'm using the TEXT_IO package.

    Right now I have:
    ------------------------------------------------------
    for tbl_rec in tbl_cur loop
    output_string:= tbl_rec.field1 || ' ' || tbl_rec.field2;
    end loop;
    ------------------------------------------------------
    I would like:
    ------------------------------------------------------
    for tbl_rec in tbl_cur loop
    output_string := ........Not sure.......
    end loop;
    ------------------------------------------------------

    I then use the TEST_IO to export the output_string variable.
    I'd like to build the fields on the fly. I've already created a loop concatencating column names from user_tab_columns and passing that into the cursor above, but all that does is return the column name the number of records in the tbl

    Any ideas? or packages you can think of?
    Thx in advance for any help

  2. #2
    Join Date
    Oct 2003
    Location
    Germany - Stuttgart
    Posts
    14
    Hi,

    maybe you can use ref-cursor:

    Define as usual

    TYPE cur_typ IS REF CURSOR;
    c cur_typ;
    l_statement varchar2(1000);
    l_result varchar2(2000);
    and then

    begin
    l_statment:='...sql-statement for concenating columns...';

    OPEN c FOR l_statement;
    LOOP
    FETCH c INTO l_result;
    EXIT WHEN c%NOTFOUND;

    do with result whatever you want...

    END LOOP;
    CLOSE c;

    Good luck

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •