can we execute unix command from oracle10g procedure

▼魔方 西西 提交于 2020-01-03 20:09:09

问题


Oracle10g in unix machine

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


回答1:


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;



回答2:


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




回答3:


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.




回答4:


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:

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

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

Run Oracle SQL-Loader from SQL or PL/SQL

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



来源:https://stackoverflow.com/questions/1058509/can-we-execute-unix-command-from-oracle10g-procedure

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!