If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > TEXT_IO ? Build tbl columns dynamically

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-03-03, 09:26
ericksob ericksob is offline
Registered User
 
Join Date: Aug 2003
Location: MN
Posts: 10
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
Reply With Quote
  #2 (permalink)  
Old 12-03-03, 17:09
Bart71 Bart71 is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On