Home » SQL & PL/SQL » SQL & PL/SQL » Re: UTL_FILE.FOPEN - opening a file size > 50k
Re: UTL_FILE.FOPEN - opening a file size > 50k [message #38898] Fri, 24 May 2002 05:36
sara
Messages: 36
Registered: February 2000
Member
Can I write the output of a cursor directly into a file using UTL_FILE?
Do have to make it a string with tab separation and then write it?
If so can you suggest how to do that.
I have modified the code that was on this site to add a cursor. any help will be very much appreciated.
DECLARE
oFile_Handle UTL_FILE.FILE_TYPE;
oFile_Name VARCHAR2(64);
oneLine VARCHAR2(4000);
START_DT VARCHAR2(200);
COUNT_ROWS NUMBER := 0 ;
-- DEFINE THE CURSOR
CURSOR cTabCols IS
SELECT API_MP_A_ID FROM API_MP_AUDIT
WHERE
TO_CHAR(TRANS_TIMESTAMP,'MM/DD/YYYY') >= START_DT;
BEGIN

oFile_Name := 'tttt.out';
oFile_Handle := UTL_FILE.FOPEN('/ct1/ctdb/output',oFile_Name,'W');
START_DT := '05/17/2002';
-- OPEN THE CURSOR
OPEN cTabCols;
LOOP
FETCH cTabCols INTO COUNT_ROWS;
IF cTabCols%ROWCOUNT = 0 THEN
-- Here I have to write to the file as 'no records'
EXIT;
ELSE
-- Here i will write the cursor records into the file.
EXIT;
END IF;
END LOOP;
LOOP
UTL_FILE.GET_LINE(iFile_Handle,oneLine);
UTL_FILE.PUTF(oFile_Handle, '%sn',oneLine);
END LOOP;
--Exception here
Previous Topic: Database Links
Next Topic: no value
Goto Forum:
  


Current Time: Fri Apr 19 22:01:35 CDT 2024