从oracle触发器调用php脚本

发布于 2024-09-27 12:22:37 字数 238 浏览 1 评论 0原文

问题如下:行插入后我有一个 oracle 触发器。从触发器中,我想调用 php 脚本并将刚刚插入的行字段作为参数传递。

插入来自非常旧的遗留应用程序,几乎没有机会查看源代码。行被频繁插入,可能一次批量插入大约 1000 行,也可能在 30 分钟内插入一行,因此每隔 5 秒检查一次该表是不可行的。

那么,想法是拥有 oracle 触发器,每次插入并调用我的 php 脚本时都会触发它?有什么想法吗?

提前致谢...

Question is following: I have an oracle trigger after row insert. From trigger, I want to call a php script and pass just inserted row fields as parameters.

Insert is coming from very old legacy application with a very little chance of looking at the source code. Rows are inserted frequently, could be batches of ~1000 rows at a time or could be one row in 30minutes, so checking this table every, let's say, 5 seconds is not an option.

So, Idea is to have oracle trigger, which would be triggered every time on insert and call my php script? Any ideas?

Thanks in advance...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清风夜微凉 2024-10-04 12:22:37

当你说“php 脚本”时,你的字面意思是命令行脚本,还是通过 apache/etc 运行的一段 php。

如果是前者,那就选择 OMG Ponies。否则我会使用 UTL_HTTP 来制作调用 Apache/PHP。实际上,我可能会考虑使用这个(如果需要的话更新你的 php/c# )。

但请记住...触发器是事务性的...如果您绝对必须从触发器中调用,请注意您的触发器可能会运行多次(由于 查询重新启动 )并可能完全回滚,导致您的外部(可能是非事务性)php 调用现在无效。如果你的 php 无法处理这个问题,那么也许你的触发器会创建一个作业,甚至一条消息到 AQ 或其他东西中,这也会加快处理速度,你可能并不真正希望你的插入等待外部网络调用。

When you say "php script" do you literally mean a command line script, or a chunk of php being run through apache/etc.

If its the former, then go with OMG Ponies. Otherwise I'd use UTL_HTTP to make the call to Apache/PHP. Actually, I'd probably consider going with this anyway ( updating your php/c# if needed ).

Just remember though.. Triggers are transactional... if you absolutely MUST call out from a trigger be aware that your trigger may run several times ( due to query restart ) and may rollback completely, resulting in your external (presumably non-transactional) php call now being invalid. If your php can't handle this then perhaps have your trigger creating a job or even a message into an AQ or something, this would also speed up handling, you probably don't really want your insert to be waiting on an external web call.

遗忘曾经 2024-10-04 12:22:37
I want to call a php script when some row is inserted or updated in some table via oracle triggers . Currently I m using this but its not much of help.

CREATE OR REPLACE TRIGGER test_script
BEFORE INSERT OR UPDATE OR DELETE ON STATES
FOR EACH ROW
BEGIN
  -- Flags are booleans and can be used in any branching construct.
  CASE
    WHEN INSERTING THEN
      :'/! echo C:/wamp/bin/php/php5.3.5/php.exe C:/wamp/www/csv.php >> C:/wamp/www/log.txt'
    WHEN UPDATING THEN
      -- Include any code specific for when the trigger is fired from an UPDATE.
    WHEN DELETING THEN
      -- Include any code specific for when the trigger is fired from an DELETE.
  END CASE;
END;
/
I want to call a php script when some row is inserted or updated in some table via oracle triggers . Currently I m using this but its not much of help.

CREATE OR REPLACE TRIGGER test_script
BEFORE INSERT OR UPDATE OR DELETE ON STATES
FOR EACH ROW
BEGIN
  -- Flags are booleans and can be used in any branching construct.
  CASE
    WHEN INSERTING THEN
      :'/! echo C:/wamp/bin/php/php5.3.5/php.exe C:/wamp/www/csv.php >> C:/wamp/www/log.txt'
    WHEN UPDATING THEN
      -- Include any code specific for when the trigger is fired from an UPDATE.
    WHEN DELETING THEN
      -- Include any code specific for when the trigger is fired from an DELETE.
  END CASE;
END;
/
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文