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 

loading into DB2 from xls format

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


Joined: 09 Sep 2005
Posts: 124
Topics: 52
Location: Chicago

PostPosted: Mon Jan 25, 2010 5:32 pm    Post subject: loading into DB2 from xls format Reply with quote

Hi All,

I have an xls file with the data that I have to upload into DB2 table. Initially I have to upload the data into mainframe and then into DB2 table.

the format of some of the fields are not matching with the DB2 columns (for example date format, Decimal format)

I have to convert them into correct format and do the upload into DB2 table. Could some one please help on this

When I searched the forums, I have seen some one pointing to pearl script, I dont know how to use it. Appreciate your help

Thank you

Rolling Eyes
_________________
Tx
Digger
Back to top
View user's profile Send private message
papadi
Supermod


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Mon Jan 25, 2010 5:36 pm    Post subject: Reply with quote

One way is to:
save the .xls data to a tab-delimited text file,
upload the text file to the mainframe,
reformat any fields that need reformatting (using sort or some other process),
load the reformatted data into db2.
_________________
All the best,

di
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Jan 25, 2010 5:42 pm    Post subject: Reply with quote

MFdigger,


1. Save the excel file as "comma-separated fields", with double quotes as the text delimiter (only for text, not for numbers).
2. If your using DB2 v8 and higher you can use the FORMAT option of the LOAD utility

ex:

Code:

//SYSIN DD *
 LOAD REPLACE LOG NO FORMAT DELIMITED
 INTO TABLE mytable (col1 CHAR, col2 INTEGER, col3 SMALLINT,
                     col4 DECIMAL, col5 DATE)
/*
//SYSREC DD *
"blah blah one",772,-232,3.12,"2010-01-25"
"blah two",0,0,0,"2009-11-22"
/*


Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
MFdigger
Beginner


Joined: 09 Sep 2005
Posts: 124
Topics: 52
Location: Chicago

PostPosted: Tue Jan 26, 2010 2:39 pm    Post subject: Reply with quote

Hi Kolusu,

Thank you for your immed response. In DB2 table we have a field defined as (5,3)

Eg: PLM DECIMAL(5 , 3) NOT NULL

so, while formating the xls file into the dataset , how the value should be

for eg: if its 9.5
does it should show as ' 9.500' or ' 9.5'?
_________________
Tx
Digger
Back to top
View user's profile Send private message
MFdigger
Beginner


Joined: 09 Sep 2005
Posts: 124
Topics: 52
Location: Chicago

PostPosted: Tue Jan 26, 2010 2:42 pm    Post subject: Reply with quote

for example:

if the dataset is like

A char (2), B char(3), PLM decimal(5,3)

then does the dataset also should appear lke

Code:

XXYYY  9.5
or
XXYYY09.500
or
XXYYY 9.500


_________________
Tx
Digger
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Jan 26, 2010 3:48 pm    Post subject: Reply with quote

MFdigger,

it should be
Code:

"XX","YYY",9.5


See the example I posted

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 700
Topics: 63
Location: USA

PostPosted: Thu Jan 28, 2010 11:35 am    Post subject: Reply with quote

Quote:

"blah blah one",772,-232,3.12,"2010-01-25"


Are the quotes required for date?
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Jan 28, 2010 12:32 pm    Post subject: Reply with quote

Dibakar,

Date is nothing but a Char(10) field. So you need the quotes.

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 700
Topics: 63
Location: USA

PostPosted: Wed Feb 03, 2010 8:24 pm    Post subject: Reply with quote

Kolusu,

I looked at Exampl 5:Loading data in delimited file format at http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db29.doc.ugref/db2z_loadsamples.htm and it didn't have quotes. I was wondering if it is just optional. Sorry, I couldn't test it.
Back to top
View user's profile Send private message Send e-mail
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