zoukankan      html  css  js  c++  java
  • ORACLE中的FTP例子代码

    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', '21', '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', '21', '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', '21', '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', '21', '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', '21', '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', '21', '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', '21', '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', '21', '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', '21', 'ftpuser', 'ftppassword');
      ftp.rmdir(p_conn => l_conn,
                p_dir  => '/u01/app/oracle/test');
      ftp.logout(l_conn);
      utl_tcp.close_all_connections;
    END;
    /

  • 相关阅读:
    Python实现杨辉三角
    第8.30节 重写Python __setattr__方法实现属性修改捕获
    转:Cookie详解
    第8.29节 使用MethodType将Python __setattr__定义的实例方法与实例绑定
    第8.28节 Python中使用__setattr__定义实例变量和实例方法
    第8.27节 Python中__getattribute__与property的fget、@property装饰器getter关系深入解析
    第8.26节 重写Python类中的__getattribute__方法实现实例属性访问捕获
    关于open函数文件打开模式的有意思的一个现象
    第8.25节 Python风格的__getattribute__属性访问方法语法释义及使用
    转:关于Python中的lambda,这篇阅读量10万+的文章可能是你见过的最完整的讲解
  • 原文地址:https://www.cnblogs.com/xiaoL/p/4793881.html
Copyright © 2011-2022 走看看