PL/SQL FTP API binary vs ascii mode

2019-06-14 04:19发布

问题:

I've compiled successfully the package and package body from Oracle-base given by Tim Hall,

I've a .txt file in my local server which is to transfer in a remoter server: It successfully runs and got the file in remote server in the same data, when I run in binary mode follows:

set serveroutput on
DECLARE
  l_conn  UTL_TCP.connection;
BEGIN
  L_CONN := FTP.LOGIN('192.168.x.y', '21', 'username','pass');
  ftp.binary(p_conn => l_conn);
 ftp.put(p_conn      => l_conn,
          P_FROM_DIR  => 'MY_DIRECTORY',
          p_from_file => 'test.txt',
          p_to_file   => 'test_put.txt');
  ftp.logout(l_conn);
END;
/
anonymous block completed
220 (vsFTPd 2.0.5)
331 Please specify the password.
230 Login successful.
200 Switching to Binary mode.
227 Entering Passive Mode (192,168,1,232,35,205)
150 Ok to send data.
226 File receive OK.
221 Goodbye.

But when I run in ftp.ascii mode, It also run successfully too:

200 Switching to ASCII mode.

But the final output in the remote server looks like

〱⼱ㄯ㈰ㄳ‱㈺〰㨰〠慭ⰰⰰⰰⰰⰴ㤰㈵〶㜬〬丬䅴瑩湧慬â—ä ­å˜±ã€­å˜²ã„¬ä¸¬å”¬å”¬â°¬â°¬â°¬â°¬ãœ¶â¸·ã¤·ãœ¹ãŒ³ãŒ³ãŒ³ãŒ³ãŒ¬ã ®ãœ±ã¤µã€±ã˜¶ã˜¶ã˜¶ã˜¶ã˜Šã€±â¼±ã„¯ãˆ°ã„³â€±ãˆºã€°ã¨°ã˜ æ…­â°°â°°â°°â°°â°´ã¤°ãˆµã€¶ãœ¬ã€¬ä¸¬ä…´ç‘©æ¹§æ…¬â—ä ­å˜±ã€­å˜²ã„¬ä¸¬å”¬å”¬â°¬â°¬â°¬â°¬ãœ¶â¸·ã¤·ãœ¹ãŒ³ãŒ³ãŒ³ãŒ³ãŒ¬ã ®ãœ±ã¤µã€±ã˜¶ã˜¶ã˜¶ã˜¶ã˜Šã€±â¼±ã„¯ãˆ°ã„³â€±ãˆºã€°ã¨±ãˆ æ…­â°°â°°â°°â°°â°´ã¤°ãˆµã€¶ãœ¬ã€¬ä¸¬ä…´ç‘©æ¹§æ…¬â—ä ­å˜±ã€­å˜²ã„¬ä¸¬å”¬å”¬â°¬â°¬â

I've tested the same in cmd using ftp ascii mode, and runs very well;

How can I transfer in ascii mode to get actual data in the remote server in pl/sql above? Thanks in advance:)

回答1:

Are you trying to ftp files from a Linux to windows box? are the text files, having English content? It so appears like there is a character set mismatch.

The old version of ftp servers/clients supported only ASCII mode, and were later update to work with UTF-8. So, please do try updating the ftp client version.



标签: oracle plsql ftp