Write a file to SFTP using Oracle PL/SQL

前端 未结 2 1134
情深已故
情深已故 2021-01-14 00:46

I wrote a PL/SQL procedure to connect to an FTP server. I am able to write a file to that FTP server. Using the same code I tried to connect to an SFTP server, but it failed

相关标签:
2条回答
  • 2021-01-14 01:14

    SFTP requires SSH plus the implementation of a protocol. As far as my PL/SQL knowledge reaches and Google's, there are currently no available implementation of SSH or this protocol in PL/SQL. There are some alternatives:

    • Use Java in the database and open sufficient ports. Not recommended when this is the only reason to use Java in the database; it is not as well designed as PL/SQL and can be expensive to maintain by a DBA since most DBA's have no experience with it.
    • Use PL/SQL to start a job outside the database. For instance, in the past I've used often Pentaho Data Integration (formerly known as Kettle) which provides a free solution to draw your data flow from table/procedure to sftp recipient and then run it. Running from PL/SQL requires a scheduler (I always used our own because it also integrates Kettle, but you can also consider the scheduler integrated with Oracle Apps, Redwood JCS/Cronacle or others). Coding in PL/SQL then becomes something like: 'begin package.submit('SFTP it'); package.wait; end;'.

    I would go for the second option. If you need further details, please let me know.

    0 讨论(0)
  • 2021-01-14 01:18

    You can try the commercial ORA_SFTP package provided from DidiSoft:

    connection_id := ORA_SFTP.CONNECT_HOST(...
    ORA_SFTP.UPLOAD(connection_id, data, 'remote_file.dat');
    

    Disclaimer: I work for DidiSoft

    0 讨论(0)
提交回复
热议问题