WebSphere MQ Client UDF

Downloads
Highlighted
Teradata Employee

WebSphere MQ Client UDF

SQL Scalar UDF that writes varbyte or varchar arg to MQ.

README

 Purpose: SQL Scalar UDF that writes varbyte or varchar arg to MQ

Author:
Robert Hahn
Robert.Hahn@teradata.com

Support:
Author will answer questions and consider enhancment requests on a time available basis.
email: Robert.Hahn@ncr.com with any questions, suggestions, or feedback.

Contents:

Parms:
qmgr, qnm, channel, varchar message.

Comments--To Do:
Add varbyte overload.
Accept identity args and open w/MQOO_ALTERNATE_USER_AUTHORITY
for varchar, set md.Encoding and md.CodedCharSetId so that mq will convert e.g. to ebcdic
Use snprintf, strncpy (had some problem with snprintf).

Documentation:
MQConnect/MQOpen then MQPUT the varchar argument.
This can be used for single puts or parallel controlled by a where clause.
This should be run in protected mode since it causes mallocs.
Note: Update defaults for qmgr, qnm, envmq etc.

Requirements:
For MPRAS, this requires that the IBM MQ Client for MPRAS is installed on all nodes:
Obtain from here: http: www-1.ibm.com/support/docview.wss?uid=swg24000067
Similar for windows--available as part of any Websphere MQ Server distribution

Build:
Scalar UDF:
replace function emruwmq(
qmgr varchar(256), qnm varchar(256), channel varchar(256), vcmsg varchar(32000)) returns integer
language C NO SQL parameter style sql EXTERNAL NAME
'F:emruwmq:SI:cmqc:/usr/include/cmqc.h:SL:mqic:SL:mqmcs:SS:emruwmq:/home/rmh/projects/emruwmq/emruwmq.c';

select emruwmq('queue.manager.1','QUEUE1','CHANNEL1/TCP/153.64.119.177','themessage')
[from allamp where ampid <= 8 ] /* parallel--assumes allamp table with 1 row/amp */

Invoking from an insert statement trigger on table cxpmult w/varchar col2:
replace TRIGGER writeMq
after Insert on cxpmult
REFERENCING NEW table AS n
FOR EACH statement
(INSERT INTO dummy
sel emruwmq('queue.manager.1','QUEUE1','CHANNEL1/TCP/153.64.119.177',n.col2) as c1
from n
where c1 < 0;);

Tags (3)