Evaluate Weigh the pros and cons of technologies, products and projects you are considering.

What is a Decimal Data Error?

One Search400.com member writes, "Can you please tell me what a Decimal Data error is, and what is the scenario in which it is received?" Search400.com's application development expert John Blenkinsop explains.

Can you please tell me what a Decimal Data error is, and what is the scenario in which it is received?

Fields declared as numeric in files and in programs will be checked to see if they contain valid numbers when the data in them is used in a program. If they are NOT valid numbers, this is a Decimal Data Error, and unless the error is trapped in the program the program will fall over.

For example, if you receive data from another computer into a file on your system, that data might be wrong. It could contain blanks where the field defined on your machine expects a number. When the file is opened by a program and the record containing the invalid data is read, you will not get an error. But if the field containing the invalid data is read in the program, by being the Factor1 of a MOVEx operation, or either factor in an ADD, SUB, DIV, MULT etc., or on the right-hand side of an EVAL, or if it is involved in a WRITE or UPDATE operation -- then it will be checked, and then the program will fail.

If you regularly receive files that contain invalid data, and you need to correct that data, you will have to declare the fields as character and use TESTN or CHECK (or some other method) to check that the field contains valid numbers and correct the data if it does not.

Sometimes the problem occurs when a numeric field is overlaid with a different numeric definition in a data structure. For example, if you have a PACKED numeric field in the record, and the programmer defines the field as ZONED in a data structure, the zoned field will contain data in a form which is invalid for a zoned field, even though it IS valid for a packed field. In such cases, it's just a matter of taking care.

Dig Deeper on DB2 UDB (universal databases)