使用 Oracle PL/SQL 将文件写入 SFTP

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9209920/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 00:36:10  来源:igfitidea点击:

Write a file to SFTP using Oracle PL/SQL

oracleplsqlftporacle10gsftp

提问by Naveenraja Subramaniam

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. How do I connect to SFTP using PL/SQL?

我编写了一个 PL/SQL 过程来连接到 FTP 服务器。我能够将文件写入该 FTP 服务器。使用相同的代码我尝试连接到 SFTP 服务器,但它失败了。如何使用 PL/SQL 连接到 SFTP?

回答by Peter Kalef ' DidiSoft

You can try the commercial ORA_SFTPpackage provided from DidiSoft:

你可以试试滴滴提供的商业ORA_SFTP包:

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

Disclaimer: I work for DidiSoft

免责声明:我为滴滴出行工作

回答by Guido Leenders

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:

SFTP 需要 SSH 加上协议的实现。就我的 PL/SQL 知识和 Google 的知识而言,目前在 PL/SQL 中没有可用的 SSH 实现或此协议。有一些替代方案:

  • 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/Cronacleor others). Coding in PL/SQL then becomes something like: 'begin package.submit('SFTP it'); package.wait; end;'.
  • 在数据库中使用Java并打开足够的端口。当这是在数据库中使用 Java 的唯一原因时不推荐;它的设计不如 PL/SQL,而且 DBA 的维护成本可能很高,因为大多数 DBA 没有相关经验。
  • 使用 PL/SQL 在数据库外启动作业。例如,过去我经常使用Pentaho Data Integration(以前称为 Kettle),它提供了一个免费的解决方案,将您的数据流从表/过程绘制到 sftp 接收者,然后运行它。从 PL/SQL 运行需要一个调度程序(我一直使用我们自己的调度程序,因为它也集成了 Kettle,但您也可以考虑与Oracle AppsRedwood JCS/Cronacle或其他程序集成的调度程序)。在 PL/SQL 中编码然后变成这样:'begin package.submit('SFTP it'); 包。等待;结尾;'。

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

我会选择第二个选项。如果您需要更多详细信息,请告诉我。