与perl异步处理firebird事件

时间:2015-08-19 07:31:44

标签: perl events asynchronous firebird

我正在创建一个信息板应用程序,其数据来自firebird 1.5数据库。 我不想使用民意调查而是事件。

我创建了示例触发器,用于在firebird数据库中触发事件。 现在我需要一个客户端来监听和处理事件。 我决定和perl一起去​​。 这是文档DBD::Firebird。 我正在尝试使用异步事件。

这是代码,我给出了无论如何都无法工作的骨架。

该事件不会在perl中启动。我究竟做错了什么。请帮忙,谢谢!

DECLARE
   request     UTL_HTTP.REQ;
   response    UTL_HTTP.RESP;
   n           NUMBER;
   buff        VARCHAR2 (4000);
   clob_buff   CLOB;
BEGIN
   UTL_HTTP.SET_RESPONSE_ERROR_CHECK (FALSE);
   UTL_HTTP.set_transfer_timeout (2);
   request := UTL_HTTP.BEGIN_REQUEST ('www.google.com:81', 'GET');
   UTL_HTTP.SET_HEADER (request, 'User-Agent', 'Mozilla/4.0');
   response := UTL_HTTP.GET_RESPONSE (request);
   DBMS_OUTPUT.PUT_LINE (
      'HTTP response status code: ' || response.status_code);  
EXCEPTION
   WHEN UTL_HTTP.transfer_timeout
   THEN
      DBMS_OUTPUT.put_line ('Timeout');
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line ('Exception in others  :' || SQLERRM);
END;

更新: 好的,这是我现在要使用的PHP脚本,只需将它留在这里也许它可以帮助某人:

#!/usr/bin/perl

use DBI;

$dsn =<< "DSN";
dbi:Firebird:dbname=/home/firebird/dev/db.gdb;
host=localhost;
port=3050;
ib_dialect=3;
DSN

$dbh =  DBI->connect($dsn, "user", "password");

# events of interest
@event_names = ("schedule_event");

$evh = $dbh->func(@event_names, 'ib_init_event');

my $cb = sub {.
    print "got event";
};

$dbh->func($evh, $cb, 'ib_register_callback');

while (1) {
}

0 个答案:

没有答案