Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Query on DB2 Integer vs cobol numeric data type!

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Query on DB2 Integer vs cobol numeric data type!
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

Site Director


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

PostPosted: Fri Jun 10, 2011 12:08 pm    Post subject:
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    Post subject: Reply to: Query on DB2 Integer vs cobol numeric data type!
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Fri Jun 10, 2011 12:25 pm    Post subject: Re: Query on DB2 Integer vs cobol numeric data type!
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10309
Location: italy

PostPosted: Fri Jun 10, 2011 12:31 pm    Post subject: Reply to: Query on DB2 Integer vs cobol numeric data type!
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    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
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts Setting Font Type for XMIT satish.ms10 All Other Mainframe Topics 3 Fri Sep 15, 2017 10:01 pm
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am
No new posts Return a Non Numeric value from REXX Learncoholic CLIST & REXX 3 Fri Sep 01, 2017 8:33 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us