Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> UTL_FILE and Ampersand (&)
Hi all,
I am trying to write multiple files to the utl_file_dir which is set
to /tmp on my server. I am trying to generate multiple files - one
file per customer and there are 1000 customers. One of the customers
is A&P Stores. My code fails because if the ampersand. Is there a
solution to this? In SQL*Plus I could say "set define off" but in
PL/QSL ....Here is my code
l_file UTL_FILE.file_type; l_last_filename varchar2(255) := '0000000'; l_cust varchar2(35) := '00000_Q.XLS'; l_custid varchar2(6) :=' '; l_custnm varchar2(35) := ' '; l_custid_prev varchar2(6) := ' '; l_custid_curr varchar2(6) := ' ';Begin
FOR cust_rec in ( select distinct cust_corp_nm,cust_corp_id from cso.cust_corp_ppl_vw) LOOP l_cust:=cust_rec.cust_corp_nm||' Q.XLS'; l_file := UTL_FILE.FOPEN('/tmp',l_cust,'w',32767); IF l_cust <> l_last_filename THEN UTL_FILE.PUT_LINE(l_file,'Customer Scorecard '); UTL_FILE.PUT_LINE(l_file,'|'); UTL_FILE.PUT_LINE(l_file,'VOLUME (Quota and Forecast)'); UTL_FILE.PUT_LINE(l_file,'|'||header_rec.h2); UTL_FILE.PUT_LINE(l_file,'PROMOTIONAL EXECUTION'); END IF; FOR promo_rec in ( select c.brd_alt_ds c79, to_char(c.event_start_dt,'yyyy-mm-dd') c80, to_char(c.price_amt,'999.99') c81 from cso.PROMO_QTRLY_TMP c where c.cust_corp_nm =cust_rec.CUST_corp_nm) LOOP UTL_FILE.PUT_LINE(l_file, '|'||nvl(promo_rec.c79,0) ||'|'); END LOOP; IF (UTL_FILE.IS_OPEN(l_file)) THEN UTL_FILE.FCLOSE(l_file); END IF; End Loop;
![]() |
![]() |