在 SQL 中,QAnywhere SQL 允许您执行 QAnywhere .NET API、C++ API 和 Java API 的许多消息传递功能。此功能包括创建消息、设置或获取消息属性和内容、发送和接收消息、触发消息同步,以及设置和获取消息存储库属性。
使用 QAnywhere SQL 生成的消息也可以由使用编程 API 创建的客户端接收。如果已在服务器上配置了一个 JMS 连接器,则消息也可由 JMS 客户端接收。同样,QAnywhere SQL 可用来接收由 QAnywhere .NET、C++、Java API 或 JMS 客户端生成的消息。
QAnywhere SQL 消息传递与用户事务共存。这表示,在提交事务时将提交该连接上的所有 QAnywhere 操作。
只有具备 DBA 特权的用户才能自动具备执行 QAnywhere 存储过程的权限。要对某个用户授予权限,具有 DBA 特权的用户必须调用过程 ml_qa_grant_messaging_permissions。
请参见ml_qa_grant_messaging_permissions。
QAnywhere SQL API 不支持 IMPLICIT_ACKNOWLEDGEMENT 或 EXPLICIT_ACKNOWLEDGEMENT 模式。通过 SQL API 进行的所有消息传递均是事务性的。
以下示例在库存表中创建一个触发器。当一个项的库存低于特定的阀值时,此触发器将发送一条消息。在提交调用此触发器的事务后,将会发送消息。如果事务被回退,则不发送消息。
CREATE TRIGGER inventory_trigger AFTER UPDATE ON inventory REFERENCING old AS oldinv new AS newinv FOR EACH ROW begin DECLARE msgid VARCHAR(128); IF oldinv.quantity > newinv.quantity AND newinv.quantity < 10 THEN -- Create the message SET msgid = ml_qa_createmessage(); -- Set the message content CALL ml_qa_settextcontent( msgid, 'Inventory of item ' || newinv.itemname || ' has fallen to only ' || newinv.quantity ); -- Make the message high priority CALL ml_qa_setpriority( msgid, 9 ); -- Set a message subject CALL ml_qa_setstringproperty( msgid, 'tm_Subject', 'Inventory low!' ); -- Send the message to the inventoryManager queue CALL ml_qa_putmessage( msgid, 'inventoryManager' ); end if; end |
Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1 |