3

我有一个关于我必须使用的数据库系统的问题:Sybase SQL Anywhere 10。我有两个应用程序,它们都与数据库通信。应用程序 A 读取/写入数据库,而应用程序 B 是一个 Web 应用程序,仅显示有关数据库的信息并缓存大量数据库查询。

问题是,我想在 App B 中获得有关特定表中数据库更改的通知,而不是一直轮询来自 App B 的更新......

我对 SQL Anywhere 10 不是很熟悉,但也许任何人都知道将这种功能添加到数据库服务器的方法。不幸的是必须直接在数据库服务器上,因为我无法控制 App A。

理想情况下,Sybase DB 服务器计数只是在特定 URL 上执行 HTTP POST 以获得通知。在这个回调中,我可以使 App B 的 Cache 失效,所以 App B 提供的缓存信息没有错误。

编辑:在@Michael的提示之后,触发器是要走的路,我正在尝试以下方法:

插入表时触发的触发器:

ALTER TRIGGER "insert_trigger" AFTER INSERT
ORDER 1 ON "M01"."Adresse"
REFERENCING NEW AS adr
FOR EACH ROW
BEGIN
CALL "DBA"."proc_http_post"(adr.id)
END

“proc_http_port”过程:

ALTER PROCEDURE "DBA"."proc_http_post"(in id integer) 
URL 'http://AppB/cache' TYPE 'HTTP:POST'

“proc_http_port”过程可能是孤立地工作的。发生的问题是,当我想在表中插入一列时,出现 SQLCODE=-187 错误,这意味着我正在尝试进行非法游标操作(请参阅:http:// /dcx.sybase.com/index.html#1001/en/dberen10/er-errm187.html)。我认为,这是因为我想获取新插入列的 id 并将其作为参数传递给 proc_http_post 过程(adr.id)。触发器是否有可能发生在事务边界内,因此无法访问 id?

我的问题是,我如何归档获取插入行的 ID 以将其传递给 Web 服务请求?

4

1 回答 1

1

so i finally figured it out by myself. the problem is, that the procedure call has to consume the response of the http request. So it has nothing to do with the actual cursor, that i thought...

for those, who have a similar problem, here is the answer: http://sqlanywhere-forum.sap.com/questions/12665/sql-trigger-http-get-procdure

here is my solution:

SET tmp = (SELECT C2 From proc_http_post(adr.AdrId) with (C1 long varchar,C2 long varchar) WHERE C1 = 'Body');
于 2013-06-14T07:06:48.227 回答