MQREAD scalar function
The MQREAD function returns a message
from the MQSeries® location
specified by receive-service, using the quality
of service policy defined in service-policy.
Executing this operation does not remove the message from the queue
associated with receive-service, but instead returns
the message at the head of the queue.
The data type of the result is VARCHAR (32000). If no messages are available to be returned, the result is the null value.
Syntax
The schema is DB2MQ for non-transactional message queuing functions, and DB2MQ1C for one-phase commit transactional MQ functions.
Function parameters
-
receive-service
- A string containing the logical MQSeries destination from where the message is to be 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 where 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, then the DB2.DEFAULT.SERVICE will be used. The maximum size of receive-service is 48 bytes. service-policy
- A string containing the MQSeries Service Policy used in handling 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, then the default DB2.DEFAULT.POLICY will be used. The maximum size of service-policy is 48 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 reads the
message at the head of the queue specified by the default service
(DB2.DEFAULT.SERVICE),
using the default policy (DB2.DEFAULT.POLICY).
VALUES MQREAD()
Example 2: This example reads the message at
the head of the queue specified by the service "MYSERVICE" using the
default policy (DB2.DEFAULT.POLICY).
VALUES MQREAD('MYSERVICE')
Example 3: This example reads the message
at the head of the queue specified by the service "MYSERVICE", and
using the policy "MYPOLICY".
VALUES MQREAD('MYSERVICE','MYPOLICY')