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

Loading SMALL INT Datatype into DB2


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

New User


Joined: 24 Jan 2007
Posts: 59
Location: Texas

PostPosted: Mon Apr 02, 2007 12:32 pm
Reply with quote

Hi,

My requiremnt is that I have to produce a file with a COBOL program which can
be loaded into a DB2 table through the IBM load utility.

Say I have Table A with COL1 of datatype SMALLINT.

I am done with the processing logic and I write the output into a file
containing just one datatype S((04) COMP, so that i can load this file in to the
table.

But the problem is something like this:
I have moved a value 27797 to the S9(04) COMP.
But only 7797 is getting populated in the variable
resulting in data loss.

But when I run an insert query I able to insert 27797 into COL1 of TableA.

I dont understand where I am going wrong.

1) Cant S9(04) COMP hold a value as big as 27797 ?
2) Is there any other dataype or declaration that I have to use?


Can somebody help me out...
Back to top
View user's profile Send private message
vini_srcna

Active User


Joined: 26 May 2005
Posts: 178
Location: Copenhagen, Denmark

PostPosted: Mon Apr 02, 2007 2:19 pm
Reply with quote

What is the equivalent datatype given by DCLGEN..?
Are you not making use of DCLGEN..?
It is meant to get rid of this kind of situations.
Back to top
View user's profile Send private message
rarvins

New User


Joined: 24 Jan 2007
Posts: 59
Location: Texas

PostPosted: Mon Apr 02, 2007 2:25 pm
Reply with quote

This is S9(04) COMP is the declarationg given by the DCLGEN
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Mon Apr 02, 2007 5:50 pm
Reply with quote

A halfword binary can hold your value, but COBOL strictly honors the field definition, which says 4 digits, so the compiled COBOL code truncates the leftmost digit.

E.g., for PIC 9(1) COMP, although a halfword is used, only unsigned single-digit values are stored.

Since PIC 9(5) COMP thru 9(9) COMP allocate a fullword, I'm not sure how you can do this directly in COBOL.

I think it is unwise to store a 5-digit number in a halfword or SMALLINT, as it will not hold any 5-digit number. That's why PIC 9(1) COMP thru 9(4) COMP use a halfword - all 4-digit values can be accomodated.
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 Split large FB file based on Key coun... DFSORT/ICETOOL 4
No new posts Secondary index error while loading d... IMS DB/DC 2
No new posts Job is loading load modules several t... COBOL Programming 12
No new posts DB2 - loading data DB2 5
No new posts Table(Unicode(Graphic) table) loading... DB2 0
Search our Forums:

Back to Top