在oracle触发器中运行exe文件 [英] run a exe file in oracle trigger

查看:323
本文介绍了在oracle触发器中运行exe文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Oracle触发器中运行 .exe 文件。
i在插入表后有oracle数据库触发器运行,我需要通过Windows触发器通过此触发器运行外部程序( exe ),如下所示:

I am trying to run a .exe file in oracle trigger. i have oracle database trigger run after inserting on table, i need to run external program(exe) by this trigger through windows command like this:

我正在尝试此代码,但没有用

i am trying this code but it dosen't work

create or replace TRIGGER GE_MAIN_NOTIFICATION_SEND AFTER INSERT ON TABLE
   REFERENCING OLD AS OLD NEW AS NEW 
   FOR EACH ROW 
BEGIN
   SYS.DBMS_SCHEDULER.create_program(
       program_name => 'UPLOADNC', 
       program_type => 'EXECUTABLE',
       program_action => 'C:\WINDOWS\SYSTEM32\CMD.exe /C c:\my_external_apps\app1.exe',
       enabled => TRUE);
END;

这是错误...如何解决

and this is the error...how to solve it

ORA-27486: insufficient privileges
ORA-06512: at "SYS.DBMS_ISCHED", line 5
ORA-06512: at "SYS.DBMS_SCHEDULER", line 36
ORA-06512: at "TEST.GE_MAIN_NOTIFICATION_SEND", line 2
ORA-04088: error during execution of trigger 'TEST.GE_MAIN_NOTIFICATION_SEND'


推荐答案

对DBMS_SCHEDULER的调用将尝试提交,因此除非您与之一起使用,否则从触发器内部无法使用自主交易。这很丑陋,但是您可以创建一个调用shell命令/可执行文件的Java存储过程。

Calls to DBMS_SCHEDULER will try to commit, so won't work from inside a trigger unless you go with autonomous transaction. It is ugly, but you can create a Java Stored Procedure that invokes the shell command / executable.

有一个完整的示例:

https://oracle-base.com/ article / 8i / shell-commands-from-plsql

但是,我建议您在可能的情况下使用纯PL / SQL进行通知(也许调用Web API(如果您正在执行类似发送SMS的操作)。

However, I'd recommend you use straight PL/SQL for your notification if possible (perhaps calling a Web API if you are doing something like sending an SMS).

这篇关于在oracle触发器中运行exe文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆