ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

How to compare these two fields (character and decimal)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to compare these two fields (character and decimal)

    I have this Exec sql:

    Exec Sql
    Select FIELD1 Into :WFLD1 FROM ECH
    Where FIELD1 = CHAR(:FIELD2)
    FETCH FIRST ROW ONLY ;

    Field 1 is define as 23 Open while Field 2 8P.

    Field 1 has a value of let say:
    00001234

    While field 2 has a value of : 1234.

    The above query was not able to determine that these two fields is the same.

    Can you help me how can i make the code to consider the leading zeros in comparing it?

    Note: Field 1 may contain other records that are not numeric. It may contain the following:
    01234ABC
    00234
    ABCDE

    How can I ignore those alphanumeric values and only retrieve records with numeric values. Then compare it to field 2?


    Appreciate your response.

    Thanks,.
Working...
X