Data Type Issue.



IBM's flagship relational database management system

Data Type Issue.

Postby Vineet » Wed Mar 21, 2012 8:10 pm

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
Vineet
 
Posts: 86
Joined: Tue Jun 19, 2007 11:38 am
Has thanked: 0 time
Been thanked: 0 time

Re: Data Type Issue.

Postby Akatsukami » Wed Mar 21, 2012 8:26 pm

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.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Data Type Issue.

Postby BillyBoyo » Wed Mar 21, 2012 8:32 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Data Type Issue.

Postby Vineet » Wed Mar 21, 2012 8:41 pm

Hi Billyboy,

Issue is When Inserting Record to the Table, where Table Col. is having the Decleration as Decimal(5,4).
Vineet
 
Posts: 86
Joined: Tue Jun 19, 2007 11:38 am
Has thanked: 0 time
Been thanked: 0 time

Re: Data Type Issue.

Postby BillyBoyo » Wed Mar 21, 2012 9:09 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Data Type Issue.

Postby GuyC » Wed Mar 21, 2012 9:53 pm

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.
GuyC
 
Posts: 315
Joined: Tue Aug 11, 2009 3:23 pm
Has thanked: 1 time
Been thanked: 4 times

Re: Data Type Issue.

Postby BillyBoyo » Thu Mar 22, 2012 5:15 am

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post