0

I have this logical source file:

A          S VALIDFLAG                 CMP(EQ '1') 
A          S ITEMPFX                   CMP(EQ 'PF')

But it seems that it works as an OR when I use the logical file using SQL. Where can I place the AND?

I checked this link but it doesn't have a sample for the AND. https://www.ibm.com/docs/en/i/7.1?topic=80-comp-comparison-keyword-physical-logical-files

I tried this but it is having an error on the AND.

A          S VALIDFLAG                 CMP(EQ '1') AND
A          S ITEMPFX                   CMP(EQ 'PF')
5
  • Is this question about IBM Information Server? If so, please tag it appropriately. Commented Aug 27, 2024 at 2:41
  • The simple answer is that an AND syntax, is not supported. Assuming that I am reading the documentation correctly. But I also I think you might be misinterpreting something when you say "But it seems that it works as an OR when I use the logical file using SQL". To me, that doesn't make design sense. You don't validate that one of the fields of a file is valid. You validate all of the fields. That suggests that there is an implicit AND. Commented Aug 27, 2024 at 2:53
  • 1
    I tagged it as ibm-midrange because I'm doing it in AS400. I have tested a record and the ITEMPFX has 'XX' and is still in the logical file. Its VALIDFLAG value is '1' so I assumed it is an implicit OR. I saw other logical files can cater AND/OR at the same time it's just that I'm not able to find the source for those so I can use as reference. Commented Aug 27, 2024 at 3:55
  • But the question is not >about< [ibm-midrange]. It is >about< [ibm-information-server]. Isn't it? Commented Aug 27, 2024 at 6:26
  • 1
    @StephenC No, it is not about [ibm-information-server]. It is about DDS defined logical files on an IBM i server, so [ibm-midrange] is the correct tag here. This question has nothing to do with [ibm-information-server] Commented Aug 27, 2024 at 20:30

1 Answer 1

3

Combining conditions with OR:

 A          S VALIDFLAG                 CMP(EQ '1') 
 A          S ITEMPFX                   CMP(EQ 'PF')

Combining conditions with AND:

 A          S VALIDFLAG                 CMP(EQ '1') 
 A            ITEMPFX                   CMP(EQ 'PF')
Sign up to request clarification or add additional context in comments.

10 Comments

I personally once encountered exactly the same problem. I found the answer in the documentation "System i Programming DDS for physical and logical files". In the section Defining a logical file using DDS, chapter Simple- and multiple-format logical files in DDS it says:
"When using the select/omit fields, specify either S or O in position 17. By specifying either S or O, the select and omit comparison statements are joined by OR. The system treats the select and omit comparison statements that are joined by OR independently from one another.
That is, if the select or omit comparison condition is met, the record is either selected or omitted. If the condition is not met, the system proceeds to the next comparison. By specifying a blank in position 17, the select and omit comparison statements are joined by AND. The combined comparisons must be met before the record is selected or omitted."
You can specify both select and omit for the same record format. The following information applies: v If you specify both select and omit for a record format, the order in which you specify them is important. The select/omit statements are processed in the order they are specified; if a record satisfies a statement, the record is either selected or omitted as specified, and remaining select/omit statements are not examined for that record
Unfortunately, I can't give a link to this document - I found it online a long time ago and downloaded it in pdf format. Try searching. There are actually 4 of them: Programming DDS concepts; Programming DDS for Display files; Programming DDS for physical and logical files; Programming DDS for Printer Files
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.