IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

What is decimal(9,2) in COBOL


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ram_vizag

Active User


Joined: 21 Aug 2008
Posts: 112
Location: hyd

PostPosted: Wed Sep 28, 2011 11:51 pm
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Thu Sep 29, 2011 12:22 am
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

Moderator Emeritus


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

PostPosted: Thu Sep 29, 2011 1:07 am
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Sep 29, 2011 1:33 am
Reply with quote

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

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
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: 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: 202
Location: Toronto, ON, Canada

PostPosted: Thu Oct 06, 2011 2:43 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top