Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Advice on Dumping a Cursor to a Text file..
In article <8c2c3p$nkc$1_at_nnrp1.deja.com>,
tim.mcconechy_at_runtime.dk wrote:
> HI!
>
> I want to make a generic Procedure in PL\SQL using UTL_FILE
>
> That will accept a cursor and
> Create a ; delimited text file based on it's contents.
>
> Has anyone out there had experience with this.
>
> The trick is to convert all file types to char and
> the fact that I don't know how many columns or what the column types
> would be..
>
> Can anyone give me any advice on how to approch this ...
>
> Thanks!
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
something like this:
create or replace function dump_csv( p_query in varchar2,
p_separator in varchar2
default ',',
p_dir in varchar2 ,
p_filename in varchar2 )
return number
is
l_output utl_file.file_type; l_theCursor integer default dbms_sql.open_cursor; l_columnValue varchar2(2000); l_status integer; l_colCnt number default 0; l_separator varchar2(10) default ''; l_cnt number default 0;
for i in 1 .. l_colCnt loop dbms_sql.column_value( l_theCursor, i, l_columnValue ); utl_file.put( l_output, l_separator || l_columnValue );l_separator := p_separator;
-- Thomas Kyte tkyte_at_us.oracle.com Oracle Service Industries http://osi.oracle.com/~tkyte/index.html -- Opinions are mine and do not necessarily reflect those of Oracle Corp Sent via Deja.com http://www.deja.com/ Before you buy.Received on Sat Apr 01 2000 - 00:00:00 CST