Search code examples
openedgeprogress-4gl

Progess 4GL - How to filter multiple records using AND operator in one table field?


I want to check and filter only if the table has value1 = 005 and value1 = 009. But it seems below query is not helping me. I dont know where I am making mistakes. Kindly help to solve this. Note - I cannot use where not as it may have many different value stored in value1 field

DEFINE TEMP-TABLE test NO-UNDO
FIELD value1 AS CHARACTER
.

EMPTY TEMP-TABLE test.

CREATE test.
ASSIGN
  value1 = "005".

CREATE test.
ASSIGN
  value1 = "009".

CREATE test.
ASSIGN
  value1 = "001".

FOR EACH test NO-LOCK
   WHERE value1 <> ""
   AND (value1 = "005" AND value1 = "009")
  :

   MESSAGE YES.
END.

Solution

  • You can use can-find

    if can-find(first test WHERE value1 = "005") 
       AND can-find(first test WHERE value1 = "009")
    then message yes.
    

    It is safest to always use can-find(first if you're looking for a non-unique value