Title: How to use operator for where filter clause?
Tags: ibm-mq;mq
Question: i know we can make use of the where filter to help get more specific result during running runmqsc. i have no problem with those operators like LT、GT、EQ、NE、LE and GE. However, as with LK、NL, it always failed. Please see the detail as below:
dis chl(SERVER.C01)
27 : dis chl(SERVER.C01)
AMQ8414: 显示通道细节。
CHANNEL(SERVER.C01)                     CHLTYPE(SVRCONN)
ALTDATE(2012-08-27)                     ALTTIME(16.05.40)
COMPHDR(NONE)                           COMPMSG(NONE)
DESCR( )                                HBINT(300)
KAINT(AUTO)                             MAXINST(999999999)
MAXINSTC(999999999)                     MAXMSGL(4194304)
MCAUSER( )                              MONCHL(QMGR)
RCVDATA( )                              RCVEXIT( )
SCYDATA( )                              SCYEXIT( )
SENDDATA( )                             SENDEXIT( )
SHARECNV(10)                            SSLCAUTH(REQUIRED)
SSLCIPH( )                              SSLPEER( )
TRPTYPE(TCP)
dis chl(*) where(type lk SVRC*)
28 : dis chl(*) where(chltype lk SVRC*)
AMQ8569: 过滤器规范中的错误
dis chl(*) where(chltype lk SVRC*
AMQ8427: MQSC 命令的有效语法为：
DISPLAY display_cmd
WHERE( filter_keyword operator filter_value )
operator := [ LT | GT | EQ | NE | LE | GE | CT | EX | LK | NL | CTG | EXG ]
In addition, how about CT and EX? Please help me out
WebSphere MQ
151.154.11.224
Thanks

Here is the accepted answer: It is not clear whether you are having this problem with other object types but as for channels, filtering based on channel type is not allowed.  This is probably because selection by type has always been supported anyway.  Just specify TYPE or CHLTYPE in the display command:
dis chl(*) chltype(svrconn)
1 : dis chl(*) chltype(svrconn)
AMQ8414: Display Channel details.
CHANNEL(SYSTEM.AUTO.SVRCONN)            CHLTYPE(SVRCONN)
AMQ8414: Display Channel details.
CHANNEL(SYSTEM.DEF.SVRCONN)             CHLTYPE(SVRCONN)
dis chl(*) type(svrconn)
2 : dis chl(*) type(svrconn)
AMQ8414: Display Channel details.
CHANNEL(SYSTEM.AUTO.SVRCONN)            CHLTYPE(SVRCONN)
AMQ8414: Display Channel details.
CHANNEL(SYSTEM.DEF.SVRCONN)             CHLTYPE(SVRCONN)
The Infocenter page for DISPLAY CHANNEL states:
Almost any parameter that can be used to display attributes for this
DISPLAY command. However, you cannot use the CMDSCOPE, QSGDISP, or
MCANAME parameters as filter keywords. You cannot use TYPE (or
CHLTYPE) if it is also used to select channels.
I'm not sure how you might use TYPE or CHLTYPE other than to select channels and I've requested a clarification made to the page to explain that.  In the meantime, be aware that selection on TYPE or CHLTYPE is not supported using the WHERE clause.  Were there cases other than channels where you had trouble with LK and NK?
UPDATE
Responding to the comment, two things to be aware of.  First, as per the Infocenter, "You cannot use a generic filter-value for parameters with numeric values or with one of a set of values."  This means, for example, that it is invalid to specify DIS CHL(*) WHERE(MCATYPE LK P*) because MCATYPE is specified by one of a set of values.  It can be only PROCESS or THREAD.  Nor would it be valid to specify DIS CHL(*) WHERE(LONGTMR LK 1*) because LONGTMR takes a numeric value.
The second item of interest is the syntax of the quoting in the WHERE clause.  Like all MQSC parameters, the WHERE clause folds unquoted values to UPPER CASE.  Since WebSphere MQ evaluates these in case-sensitive fashion, something like DIS Q(*) WHERE(DESCR LK W*) works because many of the queues have a description beginning with WebSphere and the upper case W matches.  However, DIS Q(*) WHERE(DESCR LK We*) fails because the lower case e is folded to upper case which then does not match the value in the description field.  What does work here is DIS Q(*) WHERE(DESCR LK 'We*') where the string specifier is single-quoted.
So the issues you are seeing may be due to use of the LK operator against a string value that is part of an enumeration, or possibly due to case sensitivity failing to match unquoted filter values.
The CT and CTG and their complements are the operators to use when the filter keyword is a list.  For example, in the NAMELIST object the attribute NAMES contains a list of values.  Something like WHERE(NAMES LK SYS*) would be ambiguous because LK operates on unary values.  So CT and CTG are provided as operators that work on sets.  A couple of examples to demonstrate this syntax would then be:
DIS NAMELIST(*) WHERE(NAMES CT SYSTEM.BROKER.DEFAULT.STREAM)
DIS NAMELIST(*) WHERE(NAMES CTG SYS*)
The first displays any NAMELIST objects where one of the entries in the NAMES attribute matches exactly.  The second allows a similar match based on a generic string prefix.  Be sure to quote if the expected value is in anything other than all UPPER CASE or if the value contains an embedded space.
Comment for this answer: uh....To be honest, i just wanna try use operator LK、NL、CT and EX. So i chose the attribute CHLTYPE randomly in above example, nothing special. Rob, can u give me some actual usage for operators LK and CT?
Comment for this answer: That's exactly what i need and your explanation is very clear. Thanks always Rob
Comment for this answer: Glad to help! Honestly, I learned something new researching this so the question is much appreciated. Had never used the CT or CTG before.


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2012:00:11/20/12', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<ibm-mq><mq>', 'Title': 'How to use operator for where filter clause?', 'ViewCount': 7701, 'id': 13466060, 'user_AboutMe': '', 'user_AccountId': 1425675.0, 'user_DisplayName': 'wing2ofsky', 'user_Reputation': 926.0, 'user_Views': 148.0, 'user_id': 1349261.0}}