开发者

call php script from oracle trigger

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...


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.


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;
/
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜