Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

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, 10: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, 18: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

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