mqDeleteItem

The mqDeleteItem call removes one or more user items from a bag.


Syntax for mqDeleteItem

    mqDeleteItem (Bag, Selector, ItemIndex, CompCode, Reason)


Parameters for mqDeleteItem

    Hbag (MQHBAG) - input
    Handle of the bag to be modified.

    This must be the handle of a bag created by the user, and not the handle of a system bag; MQRC_SYSTEM_BAG_NOT_ALTERABLE results if it is a system bag.

    Selector (MQLONG) - input
    Selector identifying the user item to be deleted.

    If the selector is less than zero (that is, a system selector), MQRC_SELECTOR_OUT_OF_RANGE results.

    The following special values are valid:

      MQSEL_ANY_SELECTOR
      The item to be deleted is a user item identified by the ItemIndex parameter, the index relative to the set of items that contains both user and system items.

      MQSEL_ANY_USER_SELECTOR
      The item to be deleted is a user item identified by the ItemIndex parameter, the index relative to the set of user items.

      If an explicit selector value is specified, but the selector is not present in the bag, the call succeeds if MQIND_ALL is specified for ItemIndex, and fails with reason code MQRC_SELECTOR_NOT_PRESENT if MQIND_ALL is not specified.

    ItemIndex (MQLONG) - input
    Index of the data item to be deleted. The value must be zero or greater, or one of the following special values:

      MQIND_NONE
      This specifies that there must be one occurrence only of the selector in the bag. If there is more than one occurrence, MQRC_SELECTOR_NOT_UNIQUE results. If MQIND_NONE is specified with one of the MQSEL_XXX_SELECTOR values, MQRC_INDEX_ERROR results.

      MQIND_ALL
      This specifies that all occurrences of the selector in the bag are to be deleted. If MQIND_ALL is specified with one of the MQSEL_XXX_SELECTOR values, MQRC_INDEX_ERROR results. If MQIND_ALL is specified when the selector is not present within the bag, the call succeeds.

      If MQSEL_ANY_SELECTOR is specified for the Selector parameter, the ItemIndex parameter is the index relative to the set of items that contains both user items and system items, and must be zero or greater. If ItemIndex identifies a system selector MQRC_SYSTEM_ITEM_NOT_DELETABLE results. If MQSEL_ANY_USER_SELECTOR is specified for the Selector parameter, the ItemIndex parameter is the index relative to the set of user items, and must be zero or greater.

      If an explicit selector value is specified, ItemIndex is the index relative to the set of items that have that selector value, and can be MQIND_NONE, MQIND_ALL, zero, or greater.

      If an explicit index is specified (that is, not MQIND_NONE or MQIND_ALL) and the item is not present in the bag, MQRC_INDEX_NOT_PRESENT results.

    CompCode (MQLONG) - output
    Completion code.

    Reason (MQLONG) - output
    Reason code qualifying CompCode. The following reason codes indicating error conditions can be returned from the mqDeleteItem call:

      MQRC_HBAG_ERROR
      Bag handle not valid.

      MQRC_INDEX_ERROR
      MQIND_NONE or MQIND_ALL specified with one of the MQSEL_ANY_XXX_SELECTOR values.

      MQRC_INDEX_NOT_PRESENT
      No item with the specified index is present within the bag.

      MQRC_SELECTOR_NOT_PRESENT
      No item with the specified selector is present within the bag.

      MQRC_SELECTOR_NOT_UNIQUE
      MQIND_NONE specified when more than one occurrence of the specified selector is present in the bag.

      MQRC_SELECTOR_OUT_OF_RANGE
      Selector not within valid range for call.

      MQRC_STORAGE_NOT_AVAILABLE
      Insufficient storage available.

      MQRC_SYSTEM_BAG_NOT_ALTERABLE
      System bag is read only and cannot be altered.

      MQRC_SYSTEM_ITEM_NOT_DELETABLE
      System item is read only and cannot be deleted.


Usage notes for mqDeleteItem

  1. Either a single occurrence of the specified selector can be removed, or all occurrences of the specified selector.
  2. The call cannot remove system items from the bag, or remove items from a system bag. However, the call can remove the handle of a system bag from a user bag. This way, a system bag can be deleted.


C language invocation for mqDeleteItem

mqDeleteItem (Bag, Selector, ItemIndex, &CompCode, &Reason)
Declare the parameters as follows:
MQHBAG   Hbag;          /* Bag handle */
MQLONG   Selector;      /* Selector */
MQLONG   ItemIndex;     /* Index of the data item */
MQLONG   CompCode;      /* Completion code */
MQLONG   Reason;        /* Reason code qualifying CompCode */


Visual Basic invocation for mqDeleteItem

(Supported on Windows only.)

mqDeleteItem Bag, Selector, ItemIndex, CompCode, Reason
Declare the parameters as follows:
Dim Bag       As Long 'Bag handle'
Dim Selector  As Long 'Selector'
Dim ItemIndex As Long 'Index of the data item'
Dim CompCode  As Long 'Completion code'
Dim Reason    As Long 'Reason code qualifying CompCode'
Parent topic: MQAI calls