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
 

 

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: 10256
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 Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am


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