oracle 我们可以从 oracle10g 程序执行 unix 命令吗

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1058509/
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-18 18:29:11  来源:igfitidea点击:

can we execute unix command from oracle10g procedure

oracleoracle10g

提问by kishore

Oracle10g in unix machine

unix机器上的Oracle10g

I have a requirement to execute the unix command in procedure how can I do that?

我需要在程序中执行 unix 命令,我该怎么做?

回答by Brian

BEGIN
     DBMS_SCHEDULER.create_job(
    job_name        => 'SHELL_JOB',
    repeat_interval  => 'FREQ=DAILY; BYHOUR=2',
    job_type         => 'EXECUTABLE',
    job_action       => '/u01/app/oracle/admin/tools/shell_job.sh',
    enabled          => TRUE,
    comments         => 'Perform stuff'
);
END;

回答by mamboking

You can use the DBMS_SCHEDULERpackage from Oracle. There is also an open source set of packages for doing this. You can find those here.

您可以使用Oracle的DBMS_SCHEDULER包。还有一组开源软件包可以用于执行此操作。你可以在这里找到那些。

回答by DCookie

If DBMS_SCHEDULER isn't enough for you and you need to run commands within the context of other PL/SQL code, then you will need to look into calling External Procedures.

如果 DBMS_SCHEDULER 对您来说还不够,并且您需要在其他 PL/SQL 代码的上下文中运行命令,那么您将需要考虑调用 External Procedures

回答by Moiz

I just want to share about an alternative approach for calling operating system commands. In this approach a simple web-service interface is setup for calling os commands from SQL or PL/SQL. Details about this approach can be found here:

我只想分享一种调用操作系统命令的替代方法。在这种方法中,设置了一个简单的 Web 服务接口,用于从 SQL 或 PL/SQL 调用操作系统命令。可以在此处找到有关此方法的详细信息:

Run Operating System (OS) Command in Oracle PL/SQL: A Web Service Approach

在 Oracle PL/SQL 中运行操作系统 (OS) 命令:一种 Web 服务方法

Using this approach, a step-by-step description about how to invoke SQL*Loader from SQL is also described here:

使用此方法,此处还描述了有关如何从 SQL 调用 SQL*Loader 的分步说明:

Run Oracle SQL-Loader from SQL or PL/SQL

从 SQL 或 PL/SQL 运行 Oracle SQL-Loader

Please note that in the above approach the web-service is defined in Python. Python comes pre-installed with most common linux distribution (including Oracle Linux), however if you are on windows platform then you may need to install the python 2.7.3

请注意,在上述方法中,Web 服务是用 Python 定义的。大多数常见的 linux 发行版(包括 Oracle Linux)都预装了 Python,但是如果您使用的是 windows 平台,那么您可能需要安装 python 2.7.3