Writing File in PL/SQL (newline) [message #435038] |
Mon, 14 December 2009 00:00  |
usman.javaid
Messages: 7 Registered: December 2009 Location: Pakistan
|
Junior Member |

|
|
I am writing a file in pl/sql and saving it in *.csv format but all the records are coming in same line but i want each record in separate line. i am using FND_FILE.PUT_LINE (FND_FILE.OUTPUT,........) to write file and using CHR(13)||CHR(10) for going to next line but it is not working. Can anyone help?
|
|
|
|
Re: Writing File in PL/SQL (newline) [message #435040 is a reply to message #435038] |
Mon, 14 December 2009 00:12   |
usman.javaid
Messages: 7 Registered: December 2009 Location: Pakistan
|
Junior Member |

|
|
MY CODE IS
FND_FILE.PUT_LINE (
FND_FILE.OUTPUT,
'"'
|| NVL (abc0, 0)
|| '"'
|| NVL (abc1, 0)
|| '"'
|| NVL (abc11, 0)
|| '"'
|| NVL (abc111, 0)
|| '"'
|| NVL (abc1111, 0)
|| '"'
|| NVL (abc11111, 0)
|| '"'
|| NVL (abc111111, 0)
|| '"'
|| NVL (v_Carryover, 0)
|| '"'
|| CHR(13)||CHR(10)
);
|
|
|
|
|
|
Re: Writing File in PL/SQL (newline) [message #435075 is a reply to message #435049] |
Mon, 14 December 2009 03:39   |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
You must be thinking of UTL_FILE.PUT.
From the documentation for UTL_FILE.PUT_LINE:PUT_LINE Procedure
This procedure writes the text string stored in the buffer parameter to the open file identified by the file handle. The file must be open for write operations. PUT_LINE terminates the line with the platform-specific line terminator character or characters
|
|
|
Re: Writing File in PL/SQL (newline) [message #435088 is a reply to message #435075] |
Mon, 14 December 2009 04:16   |
 |
delna.sexy
Messages: 941 Registered: December 2008 Location: Surat, The Diamond City
|
Senior Member |
|
|
JRowbottom sir
Don't know exactly, what problem I was facing and why couldn't I solve the problem at the time when I was using UTL_FILE.PUT_LINE, but following is the code which shows the correct behaviour of PUT_LINE.
SQL>select banner from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
PL/SQL Release 11.1.0.6.0 - Production
CORE 11.1.0.6.0 Production
TNS for 64-bit Windows: Version 11.1.0.6.0 - Production
NLSRTL Version 11.1.0.6.0 - Production
5 rows selected.
SQL>create directory my_dir as 'd:\my_dir';
Directory created.
SQL>declare
2 v_handle utl_file.file_type;
3 begin
4 v_handle := utl_file.fopen('MY_DIR','abc.txt','w',1000);
5
6 if(utl_file.is_open(v_handle)) then
7 utl_file.put_line(v_handle, 'Hi!', false);
8 utl_file.put_line(v_handle, 'This is Oracle PUT_LINE test.', false);
9 utl_file.put_line(v_handle, 'Thanks...', false);
10
11 utl_file.fflush(v_handle);
12
13 utl_file.fclose(v_handle);
14 end if;
15 end;
16 /
PL/SQL procedure successfully completed.
And following is the file content.
Quote:Hi!
This is Oracle PUT_LINE test.
Thanks...
regards,
Delna
|
|
|
|
|