Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
2Activity
0 of .
Results for:
No results containing your search query
P. 1
Create ASCII files using utl_file package

Create ASCII files using utl_file package

Ratings:

4.5

(2)
|Views: 635|Likes:
Published by vrbala
Create ASCII files using utl_file package
Create ASCII files using utl_file package

More info:

Categories:Types, Research
Published by: vrbala on Jun 11, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as TXT, PDF, TXT or read online from Scribd
See more
See less

05/09/2014

pdf

text

original

 
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 isl_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;beginl_output := utl_file.fopen(p_dir, p_filename, 'w');dbms_sql.parse(l_theCursor, p_query, dbms_sql.native);for i in 1 .. 255 loopbegindbms_sql.define_column(l_theCursor, i, l_columnValue, 2000);l_colCnt := i;exceptionwhen others thenif (sqlcode = -1007) thenexit;elseraise;end if;end;end loop;dbms_sql.define_column(l_theCursor, 1, l_columnValue, 2000);l_status := dbms_sql.execute(l_theCursor);loopexit when(dbms_sql.fetch_rows(l_theCursor) <= 0);l_separator := '';for i in 1 .. l_colCnt loopdbms_sql.column_value(l_theCursor, i, l_columnValue);utl_file.put(l_output, l_separator || l_columnValue);l_separator := p_separator;end loop;utl_file.new_line(l_output);l_cnt := l_cnt + 1;dbms_application_info.set_client_info(l_cnt || ' rows are generated') ;end loop;dbms_sql.close_cursor(l_theCursor);utl_file.fclose(l_output);return l_cnt;end dump_csv;-------------------------------------------------------------------------------Usage:-------------------------------------------------------------------------------declare

Activity (2)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->