Page 1 of 1

Data Type Issue.

PostPosted: Wed Mar 21, 2012 8:10 pm
by Vineet
Hi All,

I am Having COBOL + DB2 Pgm. My Current Activity is I am Reading Sequential File, Validating Each Field & Insertig Record to a Table. I am Facing issue with one of field, when Inserting Record to the Table its not getting Inserted In the Requiired Format. Datatype of table field is DECIMAL(5,4). Below is is the Example Having Actual Result & Expected Result.

Table Col. Data Type = DECIMAL(5,4).
Record 1: Value = 850 When Inserted To Table Value is +850.0000, But Expected Result is 8.50
Record 2: Value = 2025 When Inserted To Table Value is +2025.0000, But Expected Result is 20.25.
Record 3: Value = 89 When Inserted To Table Value is +89.00, But Expected Result is +00.89

I have defned Var. Having Pic. Clause as Pic 9(05) V 9(04). Please do let me know how to over come above stated Problem. Are there any Function in DB2 which can be use to Overcome the stated issue.
Please Reply ASAP.

Thanks
Kind Rgds

Vineet Anand

Re: Data Type Issue.

PostPosted: Wed Mar 21, 2012 8:26 pm
by Akatsukami
Your account seems confused. You say that you have defined a COBOL variable with PIC 9(5)V9(4) (USAGE IS DISPLAY is implied, so the data ought to be zoned decimal). Therefore, if the value is 8500000, it ought to be copied to DB2 as 850.0000. If, OTOH, the value is really 850, it would be copied as 0.0850. Neither is what you describe, so you are not describing what you are actually doing.

Re: Data Type Issue.

PostPosted: Wed Mar 21, 2012 8:32 pm
by BillyBoyo
You need to show your definition of the field in your input record. From your expected results, it would look like it should be 9(n)v99. If that is moved to your 9(5)V9(4) you would get 8.5000, 20.2500 and 0.8900.

Re: Data Type Issue.

PostPosted: Wed Mar 21, 2012 8:41 pm
by Vineet
Hi Billyboy,

Issue is When Inserting Record to the Table, where Table Col. is having the Decleration as Decimal(5,4).

Re: Data Type Issue.

PostPosted: Wed Mar 21, 2012 9:09 pm
by BillyBoyo
You say you have defined a PIC 9(5)V9(4), which matches your DB2 definition. Yet you get the wrong answer.

You say that you are getting the data from a file. You haven't shown the definition of the data on the file. You have shown what you say is the value on the file and the value that arrives in DB2.

According to what you have shown and your expected results, your definition for the data on the file is wrong. If you have defined your data on the file as PIC 9(9), or anything else without a decimal part, you will get the actual results you have shown with the data you have shown.

So, please show the definition on the file. Or change it to end in V99 (with an appropriate shortening of the first part of the definition).

It is also possible you have a correct definition on the file, for the field, but that it is not in the correct place on the file.

Re: Data Type Issue.

PostPosted: Wed Mar 21, 2012 9:53 pm
by GuyC
PIC 9(5)V9(4) USAGE IS DISPLAY does not match DB2 definition. so probably it is treated as char.
try it with COMP-3.

Re: Data Type Issue.

PostPosted: Thu Mar 22, 2012 5:15 am
by BillyBoyo
Sorry for over-stating it Guy. I was meaning the number of decimals. The actual DB2 side of it is out of my field. Or even on a different farm.

Extrapolating from the expected output, the sample data shown only has two decimal places. If there are really two more significant zeros, then I'd have stayed out of it. Yes, if "whatever" did a move of an alphanumeric to that numeric, the actual output shown should be, the way Cobol works, correct. But that would still mean the definition (of something) is wrong (somewhere), as it would mean no significant zeros to the right in the data.