automatic carriage return/line feed [message #376422] |
Wed, 17 December 2008 05:10  |
Supertd
Messages: 15 Registered: December 2008 Location: Africa
|
Junior Member |
|
|
Hi.
When writing to an output file, I notice that it automatically goes to a new line after the last line - irrespective of whether i use utl_file.put_line or utl_file.put . I noticed in notepad it prints a funny character but in another text editor is a new line. Is there any way that I can prevent the cursor from moving to a new line after writing the last line.
Please help.
Thanks.
|
|
|
|
Re: automatic carriage return/line feed [message #376435 is a reply to message #376422] |
Wed, 17 December 2008 06:04   |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
I strongly suspect that the lines that you are writing out have a carriage return character at the end of them.
From the documentation:
Quote: | No line terminator is appended by PUT; use NEW_LINE to terminate the line or use PUT_LINE to write a complete line with a line terminator.
|
|
|
|
Re: automatic carriage return/line feed [message #376489 is a reply to message #376435] |
Wed, 17 December 2008 10:02   |
_jum
Messages: 577 Registered: February 2008
|
Senior Member |
|
|
SET SERVEROUTPUT ON SIZE 1000000;
CREATE OR REPLACE DIRECTORY DC_DATA_DIR AS 'C:\TEMP';
DECLARE
--Dateiarbeit
fileHandler UTL_FILE.FILE_TYPE;
file_length NUMBER;
fexists BOOLEAN;
block_size BINARY_INTEGER;
BEGIN
BEGIN
--File aufbauen
fileHandler := UTL_FILE.FOPEN('DC_DATA_DIR' , 'FILE_1.TXT' , 'w');
UTL_FILE.PUT(fileHandler,'123');
UTL_FILE.PUT(fileHandler,'456');
UTL_FILE.PUT(fileHandler,'789');
UTL_FILE.FCLOSE(fileHandler);
UTL_FILE.FGETATTR('DC_DATA_DIR','FILE_1.TXT',fexists,file_length,block_size);
dbms_output.put_line('FILE checked');
END;
IF fexists THEN
dbms_output.put_line('FILE Length='||file_length||' BlockSize='||block_size);
ELSE
dbms_output.put_line('FILE not exists');
END IF;
END;
gives
Directory created.
FILE checked
FILE Length=11 BlockSize=0
This code puts a CR/LF at the very end of the file 3*3 Bytes + 2 (ORA 10.2.0.1.0 WINDOWS).
|
|
|
|
|