Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to delete last line from Utl_file

968361May 15 2014 — edited May 19 2014

Hi I have a requirement to write the output on a file. But whatever i try the last line is comming up as blank. I am unable to figure out why UTL_file puts last empty line as null. Is there aby wat to rectify this problem?

/

Declare

Lfilehandler  Utl_File.File_Type;

Lfilepath varchar2(100);

Lfilename varchar2(100) := 'TESTFATCAFILEGEN.txt';

Lhead VARCHAR2(2000);

Begin

Dbms_output.put_line ('Started reading the directories');

    SELECT  Filepath

      INTO    Lfilepath

      FROM   Interfacefileformathdrtbl

      WHERE  Interfaceid = 'FATCAPREXTFEED';

Dbms_output.put_line ('Directory found ');

Lhead := 'this is a test file generated to test if file generation is happening or not';

    Lfilehandler := Utl_File.Fopen(Lfilepath, Lfilename, 'W');

    Utl_File.Putf(Lfilehandler, Lhead || '\n');

    Utl_File.fclose(Lfilehandler);

   

Dbms_output.put_line ('File generation is complete');

exception

When others then

Dbms_output.put_line ('Failed in generating file');

Dbms_output.put_line ('sqlerr'||sqlerrm);

End;

/

This post has been answered by Solomon Yakobson on May 15 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 16 2014
Added on May 15 2014
13 comments
2,410 views