Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to turn a column of data into a very long comma delimited string?

Re: How to turn a column of data into a very long comma delimited string?

From: Tim X <timx_at_spamto.devnul.com>
Date: 04 Mar 2003 18:52:17 +1100
Message-ID: <87adgb7emm.fsf@tiger.rapttech.com.au>


>>>>> "Allen" == Allen Gibbons <agibbons_at_ec.rr.com> writes:

 Allen> I'm trying to take data in a single column, say 20000 records  Allen> of about 10 characters each and output them to a .CSV file.

 Allen> I have a cursor which loops through the records makes v_string  Allen> longer each time. v_string is declared as varchar2(32767)

 Allen> v_string := v_string||' '||v_string;

 Allen> This works for a small number of records, but falls down when  Allen> I hit the large number of records.

 Allen> Is there a way around this problem?

 Allen> I've been looking into the LONG data type but I'm having
 Allen> trouble concatenating the values and getting them into a
 Allen> variable of this type.

A database version would help here as a bit depends on what version you are running.

Why build up the concatenated string? You could just output the data bit by bit and then send a newline at the end of each line. If you are in the first loop, you could output the column name and the first value with a comma between. Then for each subsequent loop output a comma followed by the value.

Depending on version of db, you could possibly use utl_file or text_io.

If this is no good, consider possibly using clob rather than a long.

Tim

-- 
Tim Cross
The e-mail address on this message is FALSE (obviously!). My real e-mail is
to a company in Australia called rapttech and my login is tcross - if you 
really need to send mail, you should be able to work it out!
Received on Tue Mar 04 2003 - 01:52:17 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US