MQSEND scalar function
The MQSEND function sends the data
contained in msg-data to the MQSeries® location specified by send-service, using the quality of service policy defined
by service-policy.
An optional user-defined
message correlation identifier can be specified using correl-id.
The data type of the result is VARCHAR(1). The result of the function is '1' if successful or '0' if unsuccessful.
Syntax
The schema is DB2MQ for non-transactional message queuing functions, and DB2MQ1C for one-phase commit transactional MQ functions.
Function parameters
-
msg-data
- A string expression containing the data to be sent via MQSeries. The maximum size for a VARCHAR string expression is 32 000 bytes and the maximum size for a CLOB string expression is 1M bytes. send-service
- A string containing the logical MQSeries destination where the message is to be sent. If specified, the send-service refers to a service point defined in the DB2MQ.MQSERVICE table. A service point is a logical end-point from which a message may be sent or received. Service point definitions include the name of the MQSeries Queue Manager and Queue. If send-service is not specified, the value of DB2.DEFAULT.SERVICE is used. The maximum size of send-service is 48 bytes. service-policy
- A string containing the MQSeries Service Policy used in handling of this message. If specified, the service-policy must refer to a service policy defined in the DB2MQ.MQPOLICY table. A Service Policy defines a set of quality of service options that should be applied to this messaging operation. These options include message priority and message persistence. If service-policy is not specified, a default value of DB2.DEFAULT.POLICY will be used. The maximum size of service-policy is 48 bytes. correl-id
- An optional string containing a correlation identifier associated with this message. The correl-id is often specified in request and reply scenarios to associate requests with replies. If not specified, no correlation ID will be sent. The maximum size of correl-id is 24 bytes.
Authorization
One of the following authorities is required
to execute the function:
- EXECUTE privilege on the function
- DATAACCESS authority
- DBADM authority
- SQLADM authority
Default PUBLIC privilege
In a non-restrictive database, EXECUTE privilege is granted to PUBLIC when the function is automatically created.
Examples
Example 1: This example sends the
string "Testing 123" to the default service (DB2.DEFAULT.SERVICE), using the
default policy (DB2.DEFAULT.POLICY), with no correlation identifier.
VALUES MQSEND('Testing 123')
Example
2: This example sends the string "Testing 345" to the service "MYSERVICE",
using the policy "MYPOLICY", with no correlation identifier.
VALUES MQSEND('MYSERVICE','MYPOLICY','Testing 345')
Example 3: This example sends the string "Testing 678" to
the service "MYSERVICE", using the policy "MYPOLICY", with correlation
identifier "TEST3".
VALUES MQSEND('MYSERVICE','MYPOLICY','Testing 678','TEST3')
Example 4: This example sends the string "Testing
901" to the service "MYSERVICE", using the default policy (DB2.DEFAULT.POLICY),
and no correlation identifier.
VALUES MQSEND('MYSERVICE','Testing 901')