Has anyone sent a message to MQSeries Pub/Sub broker from PL/SQL. I am
getting a data conversion error. Here is my code:
You will see that I am building a section called mqPubHeader that is the
first part of the message data. It doesn't seem to like a hex to raw
conversion.
ORA-06502: PL/SQL: numeric or value error: hex to raw conversion error
Thanks for any help.
SET SERVEROUTPUT ON
DECLARE
objdesc PGM8.MQOD;
msgDesc PGM8.MQMD;
putOptions PGM8.MQPMO;
objectHandle binary_integer;
message VARCHAR2(255);
rawMessage raw(100);
sendMsg raw(255);
mqodRaw PGM8.MQODRAW;
mqmdRaw PGM8.MQMDRAW;
mqpmoRaw PGM8.MQPMORAW;
mqgmoRaw PGM8.MQGMORAW;
-- These are for the MQRFH Publish header
-- mqPubHeader char(85);
mqPubHeader raw(85);
rfhID char(4);
rfhVersion binary_integer;
rfhLength binary_integer;
rfhEncoding raw(4);
rfhCCSID binary_integer;
rfhFormat char(8);
rfhFlags binary_integer;
-- end of the MQRFH Publish header
-- Now the actual Publish Name/Value Strings
pubCommand char(20);
pubOptions char(18);
pubTopic char(15);
-- End of the Name/Value Strings
BEGIN
-- Populate the Publish Header
rfhID := 'RFH ';
rfhVersion := 1;
rfhLength := 85;
rfhEncoding := PGM_SUP.MQENC_NATIVE;
rfhCCSID := PGM_SUP.MQCCSI_DEFAULT;
rfhFormat := ' ';
rfhFlags := 0;
-- Populate the Name/Value Strings
pubCommand := ' MQPSCommand Publish';
pubOptions := ' MQPSPubOpts NoReg';
pubTopic := ' MQPSTopic TACS';
mqPubHeader := rfhID||rfhVersion||rfhLength||rfhEncoding||rfhCCSID||
rfhFormat||rfhFlags||pubCommand||pubOptions||pubTopic;
-- Open the queue 'YOUR_QUEUE_NAME' for sending.
-- objdesc.objectname := 'SYSTEM.BROKER.DEFAULT.STREAM';
objdesc.objectname := 'TEST.PLSQL.PUB';
-- Convert PGM8.MQMD to RAW
mqodRaw := PGM_UTL8.TO_RAW(objdesc);
[EMAIL PROTECTED](mqodRaw, PGM_SUP.MQOO_OUTPUT, objectHandle);
-- Convert RAW to PGM8.MQMD
objdesc := PGM_UTL8.RAW_TO_MQOD(mqodRaw);
-- Put the message buffer on the queue.
-- message := mqPubHeader||'Here is the message';
message := 'Here is the message';
rawMessage := UTL_RAW.CAST_TO_RAW(message);
sendMsg := mqPubHeader||rawMessage;
-- Convert PGM8.MQMD and PGM8.MQGMO to RAW
mqmdRaw := PGM_UTL8.TO_RAW(msgDesc);
mqpmoRaw := PGM_UTL8.TO_RAW(putOptions);
[EMAIL PROTECTED](objectHandle, mqmdRaw, mqpmoRaw, sendMsg);
-- Print the message we are putting on the queue
-- Close the queue again.
COMMIT;
[EMAIL PROTECTED](objectHandle, PGM_SUP.MQCO_NONE);
EXCEPTION
-- something else went wrong.. tell the user.
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Error: Procedural Gateway for IBM MQSeries
verific
ation script failed.');
DBMS_OUTPUT.PUT_LINE(SQLERRM);
[EMAIL PROTECTED](objectHandle, PGM_SUP.MQCO_NONE);
END;
/
--
Jay H. Lang
Chief Technologist
Distributed Computing Professionals Inc.
IBM Certified Specialist - MQSeries
303 277-1873 - Office
303 807-9700 - Cell
Instructions for managing your mailing list subscription are provided in
the Listserv General Users Guide available at http://www.lsoft.com
Archive: http://vm.akh-wien.ac.at/MQSeries.archive