DB2 Version 9.7 for Linux, UNIX, and Windows

MQUNSUBSCRIBE scalar function

The MQUNSUBSCRIBE function is used to unregister an existing message subscription. The subscriber-service, service-policy, and topic are used to identify the subscription that is to be cancelled. Successful execution of this function causes the publish and subscribe server to remove the specified subscription. Messages with the specified topic will no longer be sent to the logical destination defined by subscriber-service. For more details, visit http://www.ibm.com/software/MQSeries.

The data type of the result is VARCHAR(1). The result of the function is '1' if successful or '0' if unsuccessful.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-MQUNSUBSCRIBE------------------------------------------------>

>--(--+----------------------------------------------+--topic--)-><
      '-subscriber-service--,--+-------------------+-'             
                               '-service-policy--,-'               

The schema is DB2MQ for non-transactional message queuing functions, and DB2MQ1C for one-phase commit transactional MQ functions.

Function parameters

subscriber-service
If specified, the subscriber-service must refer to a Subscribers Service Point defined in the DB2MQ.MQPUBSUB table that has a type value of 'S' for publisher service. If subscriber-service is not specified, then the DB2.DEFAULT.SUBSCRIBER will be used instead. The maximum size of subscriber-service is 48 bytes.
service-policy
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 to be applied to this messaging operation. If service-policy is not specified, then the default DB2.DEFAULT.POLICY will be used. The maximum size of service-policy is 48 bytes.
topic
A string specifying the subject of messages that are not to be received. The maximum size of topic is 40 bytes. Multiple topics can be specified in one string (up to 40 bytes long). Each topic must be separated by a colon. For example, "t1:t2:the third topic" indicates that the message is associated with all three topics: t1, t2, and "the third topic".

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 cancels an interest in messages containing the topic "Weather". The default subscriber-service (DB2.DEFAULT.SUBSCRIBER) is registered as the unsubscriber and the default service-policy (DB2.DEFAULT.POLICY) specifies the quality of service.
   VALUES MQUNSUBSCRIBE('Weather')
Example 2: This example demonstrates a subscriber canceling an interest in messages containing "Stocks". The subscriber is registered as "PORTFOLIO-UPDATES" with policy "BASIC-POLICY".
   VALUES MQUNSUBSCRIBE('PORTFOLIO-UPDATES','BASIC-POLICY','Stocks')