简体   繁体   中英

How to fix file format when get it from linux server and sending it as txt format as attachment in mail?

I use PL/SQL oracle, in procedure i write data in .txt file and i save it in directory that exists in linux server by using UTL_FILE library, when i get the file from linux and send it as attachment in mail the format of file changed like below: the file in linux contain data:

00005458563722650096252557
00028282778772626667677777
63767373883899999393999999

the file when i send it as attachment in mail the data be like this:

000054585637226500962525570002828277877262666767777763767373883899999393999999

In PLSQL Developer i do the following statments in procedure to create and write the data inside file:

DIRECTORY_NAME := 'folder'
FILENAME := 'file.txt'

ftype := UTL_FILE.open(DIRECTORY_NAME , FILENAME , 'W');

// loop for 
Loop
   FETCH Result
    INTO V_WRITE_TXT
   EXIT WHEN P_RESULT %NOTFOUND;
   UTL_FILE.PUT_LINE(ftype , V_WRITE_TXT);
END LOOP;

UTL_FILE.FCLOSE(ftype);

Overview: the format of txt file in linux is correct, but when send the file by email the format changing the changes on format is merge the records in one line

if you want the windows line break in your file, you can try the put function instead of put_line

UTL_FILE.PUT (ftype , V_WRITE_TXT || chr(13) || chr(10));

The file will look strange on the Linux system. Good editors (eg Notepad ++) can now handle different line breaks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM