Consultor Eletrônico



Kbase P116022: Some database fields display correctly, but apparently do not contain valid data.
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   12/05/2006
Status: Unverified

SYMPTOM(s):

Some database fields display correctly, but apparently do not contain valid data.

A field is formatted in the dictionary as "!(1)" . The field should contain either a "U" or "L".

Displaying the data using code similar to:
FOR EACH SomeTable NO-LOCK:
DISPLAY SomeField.
END.
Displays the expected values, that is: "L" , "U"...

Displaying the data using code similar to:
FOR EACH SomeTable NO-LOCK:
DISPLAY SomeField = "U" OR SomeField = "L" FORMAT "TRUE/FALSE".
END.
Displays the unexpected values, that is: FALSE, FALSE...

CAUSE:

The actual data in the fields contain the two values "Unit" and "Lot". In the absence of an explicit FORMAT phrase, the DISPLAY statement uses the FORMAT "!(1)" as defined in the data dictionary and displays the capital form of the first letter in the string value of the field. Hence the displayed "L", "U"...
The comparison operator looks at the whole string stored in the field. Since the field actually contain the values "Unit", "Lot"... which are neither equal to "L" or "U", the expression 'SomeField = "U" OR SomeField = "L" FORMAT "TRUE/FALSE".' returns FALSE as expected.

FIX:

To display the whole string, add an appropriate FORMAT phrase to the DISPLAY statement. For example:
FOR EACH SomeTable NO-LOCK:
DISPLAY SomeField FORMAT "X(12)".
END.
To restrict the value stored in the field itself to either "L" or "U". Modify the contents of the field accordingly. For example:
FOR EACH SomeTable EXCLUSIVE-LOCK:
ASSIGN
SomeField = IF SomeField = "Unit" THEN "U" ELSE IF SomeField = "Lot" THEN "L" ELSE "ERROR".
END.