DB2 Version 9.7 for Linux, UNIX, and Windows

MQRECEIVECLOB scalar function

The MQRECEIVECLOB function returns a message from the MQSeries® location specified by receive-service, using the quality of service policy service-policy. Performing this operation removes the message from the queue associated with receive-service. If the correl-id is specified, the first message with a matching correlation identifier will be returned. If correl-id is not specified, the message at the head of the queue will be returned.

The data type of the result is CLOB(1M). If no messages are available to be returned, the result is the null value.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-MQRECEIVECLOB------------------------------------------------>

>--(--+----------------------------------------------------------+--)-><
      '-receive-service--+-------------------------------------+-'      
                         '-,--service-policy--+--------------+-'        
                                              '-,--correl-id-'          

The schema is DB2MQ.

Function parameters

receive-service
A string containing the logical MQSeries destination from which the message is received. If specified, the receive-service must refer to a Service Point defined in the DB2MQ.MQSERVICE table. A service point is a logical end-point from which a message is sent or received. Service points definitions include the name of the MQSeries Queue Manager and Queue. If receive-service is not specified, the DB2.DEFAULT.SERVICE is used. The maximum size of receive-service is 48 bytes.
service-policy
A string containing the MQSeries Service Policy to be used in the handling of this message. If specified, the service-policy must refer to a 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, the default DB2.DEFAULT.POLICY is used. The maximum size of service-policy is 48 bytes.
correl-id
A string containing an optional correlation identifier to be 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 used. 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

Examples

Example 1: This example receives the message at the head of the queue specified by the default service (DB2.DEFAULT.SERVICE), using the default policy (DB2.DEFAULT.POLICY).
   VALUES MQRECEIVECLOB()
Example 2: This example receives the message at the head of the queue specified by the service "MYSERVICE" using the default policy (DB2.DEFAULT.POLICY).
   VALUES MQRECEIVECLOB('MYSERVICE')
Example 3: This example receives the message at the head of the queue specified by the service "MYSERVICE" using the policy "MYPOLICY".
   VALUES MQRECEIVECLOB('MYSERVICE','MYPOLICY')
Example 4: This example receives the first message with a correlation ID that matches '1234' from the head of the queue specified by the service "MYSERVICE" using the policy "MYPOLICY".
   VALUES MQRECEIVECLOB('MYSERVICE',MYPOLICY','1234')