MQReadClob() function

The MQReadClob() function returns a message as a CLOB from WMQ without removing the message from the queue.

Syntax


1  MQREADCLOB (?  service_name?  , policy_name?  , correl_id  )
service_name
Optional parameter. Refers to the value in the servicename column of the "informix".mqiservice table. If service_name is not specified, IDS.DEFAULT.SERVICE is used as the service. The maximum size of service_name is 48 bytes.
policy_name
Optional parameter. Refers to the value in the policyname column of the "informix".mqipolicy table. If policy_name is not specified, IDS.DEFAULT.POLICY is used as the policy. The maximum size of policy_name is 48 bytes.
correl_id
Optional parameter. A string containing a correlation identifier to be associated with this message. The correl_id is often specified in request and reply scenarios to associate requests with replies. The maximum size of correl_id is 24 bytes. If not specified, no correlation ID is added to the message.

Usage

The MQReadClob() function returns a message as a CLOB from the WMQ location specified by service_name, using the quality-of-service policy defined in policy_name. This function does not remove the message from the queue associated with service_name. If correl_id is specified, then the first message with a matching correlation ID is returned. If correl_id is not specified, then the message at the head of the queue is returned. The result of this function is a CLOB type. If no messages are available to be returned, this function returns NULL. This function only reads committed messages.

The following table describes how the arguments for the MQReadClob() function are interpreted.
Table 1. MQReadClob() argument interpretation
Usage Argument interpretation
MQReadClob() No arguments
MQReadClob(arg1) arg1 = service_name
MQReadClob(arg1, arg2) arg1 = service_name

arg2 = policy_name

MQReadClob(arg1, arg2, arg3) arg1 = service_name

arg2 = policy_name

arg3 = correl_id

Return codes

The contents of the message as a CLOB
The operation was successful. If no messages are available, the result is NULL.
Error
The operation was unsuccessful.

Example

Example 1
begin;
EXECUTE FUNCTION MQReadClob();
commit;
Alternatively, the following syntax can be used:
insert into my_order_table(clob_col) VALUES(MQReadClob());
This example reads the content of the message as a CLOB at the head of the queue into the CLOB with the following parameters:
  • service_name: default service name
  • policy_name: default policy name
  • correl_id: None
Example 2
begin;
EXECUTE FUNCTION MQReadClob('MYSERVICE');
rollback;
Alternatively, the following syntax can be used:
insert into my_order_table(clob_col)
 VALUES(MQReadClob('MYSERVICE'));
This example reads the content of the message as a CLOB at the head of the queue into the CLOB with the following parameters:
  • service_name: "MYSERVICE"
  • policy_name: default policy name
  • correl_id: None
Example 3
begin;
EXECUTE FUNCTION MQReadClob('MYSERVICE','MYPOLICY');
commit;
Alternatively, the following syntax can be used:
insert into my_order_table(clob_col)
 VALUES(MQReadClob('MYSERVICE', 'MYPOLICY'));
This example reads the content of the message as a CLOB at the head of the queue into the CLOB with the following parameters:
  • service_name: "MYSERVICE"
  • policy_name: "MYPOLICY"
  • correl_id: None
Example 4
begin;
EXECUTE FUNCTION MQReadClob('MYSERVICE','MYPOLICY', 'TESTS');
commit;
Alternatively, the following syntax can be used:
insert into my_order_table(clob_col)
 VALUES(MQReadClob('MYSERVICE', 'MYPOLICY', 'TESTS'));
This example reads the content of the message as a CLOB at the head of the queue into the CLOB with the following parameters:
  • service_name: "MYSERVICE"
  • policy_name: "MYPOLICY"
  • correl_id: "TESTS"