Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

What is decimal(9,2) in COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
ram_vizag

New User


Joined: 21 Aug 2008
Posts: 92
Location: hyd

PostPosted: Wed Sep 28, 2011 11:51 pm    Post subject: What is decimal(9,2) in COBOL
Reply with quote

Hi,

suppose if i declare a field in db2 table with decimal data type
field decimal(9,2) in a table,

1)how many bytes it will take in db2 and how many bytes it will take in cobol??
2) In COBOL, above declaration would result in 9(9)V2 or 9(7)v2.

Kindly clarify.
Ram
Back to top
View user's profile Send private message

Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Sep 29, 2011 12:22 am    Post subject: Reply to: what is decimal(9,2)????
Reply with quote

It's most likely 5-Bytes packed-decimal with two implied decimal points.

This is similar to a PL/I definition.

COBOL would be S9(07)V99 COMP-3.

HTH....

Mr. Bill
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Sep 29, 2011 1:07 am    Post subject:
Reply with quote

Hello,

Quote:
1)how many bytes it will take in db2 and how many bytes it will take in cobol??
Why would you think the number of bytes would not be the same every this was used? If you have a field that takes 5 or 7 or 9 bytes in a file, how could it ever differ by programming language or tool usage?

Data is the same regardless of where used - it cannot be otherwise. Imaging the disaster if the sort created 7 bytes and Easytrieve believed the length was 5.

Possibly i misunderstand the concern. . .
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10211
Location: italy

PostPosted: Thu Sep 29, 2011 1:33 am    Post subject: Reply to: what is decimal(9,2)????
Reply with quote

a quick a d dirty google search with db2 cobol data types
returned

http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.db2z10.doc.apsg%2Fsrc%2Ftpc%2Fdb2z_equivalentcoboldatatypes.htm
Back to top
View user's profile Send private message
Manish Prabhakar Gokhare

New User


Joined: 20 Aug 2011
Posts: 3
Location: INDIA

PostPosted: Sat Oct 01, 2011 6:13 pm    Post subject:
Reply with quote

suppose if i declare a field in db2 table with decimal data type
field decimal(9,2) in a table,

1)how many bytes it will take in db2 and how many bytes it will take in cobol??
2) In COBOL, above declaration would result in 9(9)V2 or 9(7)v2.

==> DECIMAL (9,2) that is db2 representation will take 9/2 bytes i.e 5 byte.

==> In COBOL we declare it as PIC S9(7)v 99 comp-3. It will also take 5 byte..

Please go through DB2 mannual: http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.db2z10.doc.apsg%2Fsrc%2Ftpc%2Fdb2z_equivalentcoboldatatypes.htm
Back to top
View user's profile Send private message
jerryte

Active User


Joined: 29 Oct 2010
Posts: 183
Location: Toronto, ON, Canada

PostPosted: Thu Oct 06, 2011 2:43 am    Post subject:
Reply with quote

When a column is defined as DECIMAL(#,#) then the first number is the total number of digits including the ones to the right of the decimal point. The second number is the number of digits to the right of the decimal point. So the number of digits to the left of the decimal point is the first number minus the second number.

Thus the largest number that can be stored in DECIMAL(9,2) is 9999999.99 (there are 7 digits to the left and 2 digits to the right).

In COBOL this is a packed decimal field which uses 1 byte for every 2 digits plus an extra nibble (half a byte) for the sign. It is recommended to use an odd number as the precision so that you can make best use of the total bytes allocated.

For DECIMAL(9,2) the cobol field is PIC S9(7)V99 COMP-3.

The DB2 SQL Reference manual chapter 2 has a section on Data Types.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Full Time COBOL Software Development ... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:24 am
This topic is locked: you cannot edit posts or make replies. COBOL Software Development Lead at Fi... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:21 am
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us