I agree Chuck, it doesn't have good precedence while evaluating logical expression.
I have to use as you suggested
For condition
( Cond_A AND Cond_B ) OR ( Cond_C AND (Cond_D or Cond_E))
I will have to formulate it in WRKQRY as below. I am using WRKQRY because I don't have to promote any code for simple query extract in prod envi and I need to get output into out file.
Cond_A and CondB or Cond_C and Cond_D or Cond_C and Cond_E
Thanks Every one for the suggestion.
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of CRPence
Sent: Wednesday, March 09, 2011 12:32 PM
To: midrange-l@xxxxxxxxxxxx
Subject: Re: WRKQRY ques
On 3/9/11 9:04 AM, Ruthirapathi, Arulanandham X wrote:
I would like to create condition with logical operator OR in WRKQRY,
could you give me an example please?
Probably better to just use SQL instead, with all the free-form and
parenthetical conditional logic of the WHERE clause versus the listed
conditions in "OR groups" of the QRY feature; e.g. use STRQMQRY for a
report from a SELECT statement. Or possibly using the SQL only to
encapsulate the WHERE logic of the SELECT statement in a VIEW, if a
*QRYDFN must be used for some reason.
Each OR conditional test in the "Record Selection" screen of
Query/400 effects an implicit closed parenthesis for all prior
conditions in the list and starts an implicit open parenthesis for the
remaining conditions in the list.
Given the following list of conditions [although written
here left-to-right versus top-to-bottom] are in a Query:
Cond_A AND Cond_B OR Cond_C
that list of conditions effects the logical equivalent of:
( Cond_A AND Cond_B ) OR ( Cond_C )
However, in many cases the desired effect is instead:
Cond_A AND ( Cond_B OR Cond_C )
but per inability to specify precedence with parentheses,
the listed conditions must be written in the Query as:
Cond_A AND Cond_B OR Cond_A AND Cond_C
that list of conditions effects the logical equivalent of:
( Cond_A AND Cond_B ) OR ( Cond_A AND Cond_C )
Regards, Chuck
As an Amazon Associate we earn from qualifying purchases.