http://blog.csdn.net/mashengwang/article/details/5982663
CREATE OR REPLACE DIRECTORY my_docs as '/u01/app/oracle/';
SET serveroutput on SIZE 1000000
@c:/ftp.pks
@c:/ftp.pkb
--Retrieve an ASCII file from a remote FTP server.
DECLARE
L_conn utl_tcp.connection;
BEGIN
L_conn: = Ftp.login (' ftp.company.com ', ' + ', ' ftpuser ', ' FTPPassword ');
Ftp.ascii (p_conn = l_conn);
Ftp.get (P_conn = L_conn,
P_from_file = '/u01/app/oracle/test.txt ',
P_to_dir = ' My_docs ',
P_to_file = ' test_get.txt ');
Ftp.logout (L_conn);
Utl_tcp.close_all_connections;
END;
/
--Send an ASCII file to a remote FTP server.
DECLARE
l_conn utl_tcp.connection;
BEGIN
L_conn: = Ftp.login (' ftp.company.com ', ' + ', ' ftpuser ', ' FTPPassword ');
Ftp.ascii (p_conn = l_conn);
Ftp.put (p_conn = l_conn,
p_from_dir = ' My_docs ',
p_ From_file = ' Test_get.txt ',
p_to_file = > '/u01/app/oracle/test_put.txt ');
Ftp.logout (l_conn);
Utl_tcp.close_all_connections;
END;
/
--Retrieve a binary file from a remote FTP server.
DECLARE
l_conn utl_tcp.connection;
BEGIN
L_conn: = Ftp.login (' ftp.company.com ', ' + ', ' ftpuser ', ' FTPPassword ');
Ftp.binary (p_conn = l_conn);
Ftp.get (p_conn = l_conn,
p_from_file = '/u01/app/oracle/product/9.2.0.1.0/sysman/reporting/gif/jobs.gif ',
p_to_dir = ' My_docs ',
p_to_file = ' jobs_get.gif ');
Ftp.logout (l_conn);
Utl_tcp.close_all_connections;
END;
/
--Send a binary file to a remote FTP server.
DECLARE
l_conn utl_tcp.connection;
BEGIN
L_conn: = Ftp.login (' ftp.company.com ', ' + ', ' ftpuser ', ' FTPPassword ');
Ftp.binary (p_conn = l_conn);
Ftp.put (p_conn = l_conn,
p_from_dir = ' My_docs ',
p_ From_file = ' jobs_get.gif ',
p_to_file = > '/u01/app/oracle/jobs_put.gif ');
Ftp.logout (l_conn);
Utl_tcp.close_all_connections;
END;
/
--Get a directory listing from a remote FTP server.
DECLARE
l_conn utl_tcp.connection;
l_list ftp.t_string_table;
BEGIN
L_conn: = Ftp.login (' ftp.company.com ', ' + ', ' ftpuser ', ' FTPPassword ');
Ftp.list (p_conn = l_conn,
p _dir = '/u01/app/oracle ',
p_list = l_list);
Ftp.logout (l_conn);
Utl_tcp.close_all_connections;
IF l_list. COUNT > 0 Then
for I in L_list.first. L_list.last LOOP
dbms_ Output.put_line (I | | ': ' | | L_list (i));
END LOOP;
END IF;
END;
/
--Rename a file on a remote FTP server.
DECLARE
l_conn utl_tcp.connection;
BEGIN
L_conn: = Ftp.login (' ftp.company.com ', ' + ', ' ftpuser ', ' FTPPassword ');
Ftp.rename (p_conn = l_conn,
P_from = '/u01/app/oracle/dba/shutdown ',
p_to = '/u01/app/oracle/dba/shutdown.old ');
Ftp.logout (l_conn);
Utl_tcp.close_all_connections;
END;
/
--Delete a file on a remote FTP server.
DECLARE
L_conn utl_tcp.connection;
BEGIN
L_conn: = Ftp.login (' ftp.company.com ', ' + ', ' ftpuser ', ' FTPPassword ');
Ftp.delete (P_conn = L_conn,
P_file = '/u01/app/oracle/dba/temp.txt ');
Ftp.logout (L_conn);
Utl_tcp.close_all_connections;
END;
/
--Create A directory on a remote FTP server.
DECLARE
L_conn utl_tcp.connection;
BEGIN
L_conn: = Ftp.login (' ftp.company.com ', ' + ', ' ftpuser ', ' FTPPassword ');
Ftp.mkdir (P_conn = L_conn,
P_dir = '/u01/app/oracle/test ');
Ftp.logout (L_conn);
Utl_tcp.close_all_connections;
END;
/
--Remove A directory from a remote FTP server.
DECLARE
L_conn utl_tcp.connection;
BEGIN
L_conn: = Ftp.login (' ftp.company.com ', ' + ', ' ftpuser ', ' FTPPassword ');
Ftp.rmdir (P_conn = L_conn,
P_dir = '/u01/app/oracle/test ');
Ftp.logout (L_conn);
Utl_tcp.close_all_connections;
END;
/
FTP Example code in Oracle