/* Formatted on 1/15/2012 11:58:56 PM (QP5 v5.163.1008.3004) */
CREATE OR REPLACE PROCEDURE SYS.oracle_to_mq (local_queue IN VARCHAR2,
MESSAGE IN VARCHAR2)
AS
objdesc PGM.MQOD;
hobj PGM.MQOH;
msgdesc PGM.MQMD;
putmsgopts PGM.MQPMO;
getmsgopts PGM.MQGMO;
options BINARY_INTEGER;
putbuffer RAW (32767) := UTL_RAW.cast_to_raw (MESSAGE);
BEGIN
DBMS_OUTPUT.put_line ('message put on queue = ' || RAWTOHEX (putbuffer));
-- 以下可以指定用到的dblink名字和put方法用到的queue
objdesc.objectname := local_queue;
objdesc.dblinkname := 'dg4mqs';
-- 定义打开queue的option
options := pgm_sup.MQOO_OUTPUT;
-- 打开queue
PGM.MQOPEN (objdesc, options, hobj);
-- 调用put方法把putbuffer放入queue
PGM.MQPUT (hobj,
msgdesc,
putmsgopts,
putbuffer);
-- 定义关闭queue的option
options := pgm_sup.MQCO_NONE;
-- 关闭queue
PGM.MQCLOSE (hobj, options);
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Error: Failed to put the message');
DBMS_OUTPUT.put_line (SQLERRM);
ROLLBACK;
END;
/
阅读(769) | 评论(0) | 转发(0) |