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;
/