mqCountItems
The mqCountItems call returns the number of occurrences of user items, system items, or both, that are stored in a bag with the same specific selector.
Syntax for mqCountItems
- mqCountItems (Bag, Selector, ItemCount, CompCode, Reason)
Parameters for mqCountItems
- Bag (MQHBAG) - input
- Handle of the bag with items that are to be counted. This can be a user bag or a system bag.
- Selector (MQLONG) - input
- Selector of the data items to count.
If the selector is less than zero (a system selector), the selector must be one that is supported by the MQAI. MQRC_SELECTOR_NOT_SUPPORTED results if it is not.
If the specified selector is not present in the bag, the call succeeds and zero is returned for ItemCount.
The following special values can be specified for Selector:- MQSEL_ALL_SELECTORS
- All user and system items are to be counted.
- MQSEL_ALL_USER_SELECTORS
- All user items are to be counted; system items are excluded from the count.
- MQSEL_ALL_SYSTEM_SELECTORS
- All system items are to be counted; user items are excluded from the count.
- ItemCount (MQLONG) - output
- Number of items of the specified type in the bag (can be zero).
- CompCode (MQLONG) - output
- Completion code.
- Reason (MQLONG) - output
- Reason code qualifying CompCode.
The following
reason codes indicating error conditions can be returned from the mqCountItems call:
- MQRC_HBAG_ERROR
- Bag handle not valid.
- MQRC_ITEM_COUNT_ERROR
- ItemCount parameter not valid (invalid parameter address).
- MQRC_SELECTOR_NOT_SUPPORTED
- Specified system selector not supported by the MQAI.
- MQRC_SELECTOR_OUT_OF_RANGE
- Selector not within valid range for call.
Usage notes for mqCountItems
This call counts the number of data items, not the number of unique selectors in the bag. A selector can occur multiple times, so there might be fewer unique selectors in the bag than data items.
C language invocation for mqCountItems
mqCountItems (Bag, Selector, &ItemCount, &CompCode, &Reason);Declare the parameters as follows:
MQHBAG Bag; /* Bag handle */ MQLONG Selector; /* Selector */ MQLONG ItemCount; /* Number of items */ MQLONG CompCode; /* Completion code */ MQLONG Reason; /* Reason code qualifying CompCode */
Visual Basic invocation for mqCountItems
(Supported on Windows only.)
mqCountItems Bag, Selector, ItemCount, CompCode, ReasonDeclare the parameters as follows:
Dim Bag; As Long 'Bag handle' Dim Selector As Long 'Selector' Dim ItemCount As Long 'Number of items' Dim CompCode As Long 'Completion code' Dim Reason As Long 'Reason code qualifying CompCode'Parent topic: MQAI calls