Bharat
Bharat

Reputation: 177

How to check negative integer values ? - PROGRESS 4GL

I have written a below query to see what are the possitive and negative integer values from a table fields. But I am not sure how to fetch only negative integer values.

DEFINE TEMP-TABLE ttdata NO-UNDO
FIELD iValue1 AS INTEGER
FIELD iValue2 AS INTEGER
.

CREATE ttdata.
ASSIGN
iValue1 = 122
iValue2 = -122
.

FOR EACH ttdata NO-LOCK:
  DISP iValue1 iValue2.
END.

Upvotes: 0

Views: 489

Answers (2)

FloW
FloW

Reputation: 1266

a query just about one field where field < 0

FOR EACH ttdata NO-LOCK 
   WHERE ttData.iValue2 < 0:
    DISP iValue1 iValue2.
END.

when you have two fields with or

FOR EACH ttdata NO-LOCK 
   WHERE ttData.iValue2 < 0 
      OR ttData.iValue1 < 0:
    DISP iValue1 iValue2.
END.

but when you use the where or on a database table, you should have 2 indexes where iValue1 and iValue2 is the first field, otherwise it will be slow and a full table scan. On a temp-table it will be fine without an index

Upvotes: 3

Tom
Tom

Reputation: 5667

You could use WHEN expressions :

FOR EACH ttdata NO-LOCK:
  DISPLAY ttdata.iValue1 WHEN ttdata.iValue1 < 0 
          ttdata.iValue2 WHEN ttdata.iValue2 < 0.
END.

Upvotes: 1

Related Questions