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

Query on DB2 Integer vs cobol numeric data type!


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

New User


Joined: 18 Jun 2008
Posts: 54
Location: Colombo

PostPosted: Fri Jun 10, 2011 11:56 am
Reply with quote

Hi,

In cobol program, i have a numeric value 1234567890 which need to be loaded into a integer field of a table.

Hence I move these 10 digits to a S9(9) comp variable. After the movement, i see only 9 digits 234567890 in the output.

S9(9) COMP is equivalent of db2 integer. Integer can hold values up to 10 digits(-2147483648 till +2147483648) whereas cobol datatype holds only 9 digits.

This seems to be a contradiction. Please help me if you have any idea.

With Regards,
Vijay
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: Fri Jun 10, 2011 12:08 pm
Reply with quote

Hello,

When you tell cobol 9, you are limited to 9 (even though the storage could actually hold a bit more).

Quote:
S9(9) COMP is equivalent of db2 integer.
Ah, well, not quite. . .

s9(9) comp will fit into an integer field, but is not "equivalent".
Back to top
View user's profile Send private message
cvijay784
Warnings : 1

New User


Joined: 18 Jun 2008
Posts: 54
Location: Colombo

PostPosted: Fri Jun 10, 2011 12:22 pm
Reply with quote

Thanks for letting me know that S9(9) comp will fit in Integer type but not exact equivalent.

I think S9(10) comp will be an equivalent when the values are limited between -2147483648 & +2147483648.

With Regards,
Vijay
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Jun 10, 2011 12:25 pm
Reply with quote

cvijay784 wrote:
Hi,

In cobol program, i have a numeric value 1234567890 which need to be loaded into a integer field of a table.

Hence I move these 10 digits to a S9(9) comp variable. After the movement, i see only 9 digits 234567890 in the output.

S9(9) COMP is equivalent of db2 integer. Integer can hold values up to 10 digits(-2147483648 till +2147483648) whereas cobol datatype holds only 9 digits.

This seems to be a contradiction. Please help me if you have any idea.

With Regards,
Vijay


If you look at the Cobol forum there was a recent discussion (couple of weeks ago) of the maximum value that can be held in a binary field, and there you'll see that it is possible to get the same range (hint for the search) in a Cobol full-word.

You are not quite accurate about the DB2. It can sometimes successfully contain 10 digits, sometimes not. Try +2147483649. Try +9999999999.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Jun 10, 2011 12:31 pm
Reply with quote

a binary fullword will hold a value from -2**31 to +2**31 aka -2147483648 to +2147483648
which are 10 digits, but there is gotcha the first digit goes up to 2

a cobol s9(10) expects to hold 10 digits numbers between 0 and 9999999999

so, carry on Your conclusions!

the cobol architecture will prevent in this case full use of a fixed bin 31 ( like PL/1 does )
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 Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Store the data for fixed length COBOL Programming 1
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
Search our Forums:

Back to Top