MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DB2 Conversion (Integer)

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
monaco
Beginner


Joined: 20 May 2004
Posts: 77
Topics: 31

PostPosted: Thu Dec 02, 2004 5:57 am    Post subject: DB2 Conversion (Integer) Reply with quote

Hi,

We try to load data from a text file onto a DB2 database. In this specific case the data we load is identified as INTEGER on DB2, but in the text file we have 10 digits / characters.

Is there a routine to load these digits into a DB2 column with INTEGER format? We understand that the an INTEGER can hold up to 10 digits, but whenever we try to load the data, the result we see in DB2 is not what we had in the text file. We also understand that there is some compression going on, but we do not know when and where.

Could you please let us know, if there is any routine for loading such data?

Thanks a lot,
Andrea
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Dec 02, 2004 8:24 am    Post subject: Reply with quote

Monaco,

You can run the text file thru a sort to convert the numeric into integer format.

An integer in DB2 is equivalent to S9(9) Comp in cobol. It is Binary full-word (4 bytes) and can be used to stroe values -2,147,483,648 through +2,147,483,647

For example if your input has the 10 digit number at pos 5 then you can use the following job to convert them to integer format
Code:

//STEP0100 EXEC PGM=SORT               
//SYSOUT   DD SYSOUT=*                 
//SORTIN   DD *                         
----+----1----+----2----+----3----+----4
ABC -2147483648                         
DEF  2147483647                         
//SORTOUT  DD SYSOUT=*                 
//SYSIN    DD *                         
 SORT FIELDS=COPY                       
 OUTREC FIELDS=(1,4,5,11,FS,FI,LENGTH=4)   
/*                                     


If your text file does not have negative numbers then you can simply use binary(BI) format

Code:

//STEP0100 EXEC PGM=SORT               
//SYSOUT   DD SYSOUT=*                 
//SORTIN   DD *                         
----+----1----+----2----+----3----+----4
ABC 2147483648                         
DEF 2147483647                         
//SORTOUT  DD SYSOUT=*                 
//SYSIN    DD *                         
 SORT FIELDS=COPY                       
 OUTREC FIELDS=(1,4,5,10,ZD,FI,LENGTH=4)   
/*                                     


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
monaco
Beginner


Joined: 20 May 2004
Posts: 77
Topics: 31

PostPosted: Fri Dec 03, 2004 4:21 am    Post subject: Reply with quote

Thanks Kolusu.
Its works.
Back to top
View user's profile Send private message
Uttank
Beginner


Joined: 12 Feb 2004
Posts: 12
Topics: 9

PostPosted: Wed Jan 05, 2005 6:49 am    Post subject: Query reqarding the solution provided? Reply with quote

I could not understand certain things in the solution provided below.
They are as follows :
1) Can you pls explain the step :
OUTREC FIELDS=(1,4,5,11,FS,FI,LENGTH=4)

I could not understand the conversion and what is meant by 1,4,5,11?
And 'FS','FI' ,'ZD' and length = 4.

Thanks
Uttank
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Wed Jan 05, 2005 6:59 am    Post subject: Reply with quote

Uttank,

Check this link for a detailed explanation of the DFSORT'S OUTREC parm

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA00/3.14?DT=20031124143823

check this link for detailed explanation on DFSORT'S Data formats.

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA00/C.1?DT=20031124143823

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
videlord
Beginner


Joined: 09 Dec 2004
Posts: 147
Topics: 19

PostPosted: Wed Jan 05, 2005 9:45 pm    Post subject: Reply with quote

Did you try using INTEGER EXTERNAL(length) when Loading data?
DB2 LOAD UTILITY accept a string of characters that represent a number.

Regards,
Charlie
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group