Home » SQL & PL/SQL » SQL & PL/SQL » automatic carriage return/line feed (pl/sql)
automatic carriage return/line feed [message #376422] Wed, 17 December 2008 05:10 Go to next message
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 #376428 is a reply to message #376422] Wed, 17 December 2008 05:56 Go to previous messageGo to next message
Michel Cadot
Messages: 68733
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Not in PL/SQL.

Regards
Michel
Re: automatic carriage return/line feed [message #376435 is a reply to message #376422] Wed, 17 December 2008 06:04 Go to previous messageGo to next message
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 Go to previous messageGo to next message
_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).

Re: automatic carriage return/line feed [message #376491 is a reply to message #376489] Wed, 17 December 2008 10:12 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
Good demonstration.
Re: automatic carriage return/line feed [message #376525 is a reply to message #376422] Wed, 17 December 2008 12:47 Go to previous message
coleing
Messages: 213
Registered: February 2008
Senior Member
Another option:-

You can also use this to write to files. This might get around your EOF issue.

DBMS_XSLPROCESSOR.CLOB2FILE(
cl IN CLOB;
flocation IN VARCHAR2,
fname IN VARCHAR2,
csid IN NUMBER:=0);


Previous Topic: Complex SQL Statement - Comparing Strings
Next Topic: Views vs Materialized Views
Goto Forum:
  


Current Time: Sat Feb 08 20:55:46 CST 2025