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 Text files into DB2 tables

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


Joined: 23 Feb 2003
Posts: 26
Topics: 22
Location: chennai

PostPosted: Thu Mar 13, 2003 1:06 am    Post subject: loading Text files into DB2 tables Reply with quote

Hi

I have got data from the client in TEXT files.I don't have the SYSPUNCH(position and others).Each colmns is seperated by delimiter in text files.

How to load the data into tables from the text files.What should I give in the SYSIN.

regards

JASHU
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 Mar 13, 2003 11:38 am    Post subject: Reply with quote

Jashu,

There are 2 ways of doing it.
Option:1

Run the text file thru sort/easytrieve to remove the delimiter and just load the data using
the following control card
Code:

LOAD DATA INDDN(SYSREC00) REPLACE YES
          INTO TABLE TABLENAME


Option:2

Unload the table which you are trying to load so that it will generate a load card.use a where clause in the sql with primary key > 999999999 , so that it will not unload any rows.
Code:

//STEP0100 EXEC PGM=IKJEFT01                 
//*                                         
//SYSTSPRT DD  SYSOUT=*,DCB=BLKSIZE=121     
//SYSPRINT DD  SYSOUT=*                     
//SYSTSIN  DD  *                             
DSN SYSTEM(XXXX)                           
RUN  PROGRAM(DSNTIAUL) -                   
      PLAN(DSNTIAUL)    -                   
      PARMS('SQL')      -                   
      LIB('XXXX.RUNLIB.LOAD') 
//SYSREC00 DD DUMMY             
//SYSPUNCH DD DSN=YOUR LOAD CARD FILE,       
//            DISP=(NEW,CATLG,DELETE),       
//            UNIT=SYSDA,                     
//            SPACE=CYL,(1,1),RLSE)                 
//SYSIN    DD  *                             
SELECT *                                     
     FROM                                   
     TABLE NAME
      WHERE PRIMARY KEY > '999999999999'                             
             ;                               
/*

Now the syspunch data set will have something like this

Code:

LOAD DATA INDDN(SYSREC00) REPLACE YES
          INTO TABLE TABLENAME
        (COL1      POSITION (1:3)     CHAR(3),
         COL2      POSITION (4:39)    CHAR(36),
         COL3      POSITION (40:45)   CHAR(6),
         COL4      POSITION (46:48 )   CHAR(3),
         COL5      POSITION (49:64)   CHAR(16) )


Now you can edit this syspunch dataset by incrementing the start position and load the table using the edited control cards.


Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Manas Biswal
Intermediate


Joined: 29 Nov 2002
Posts: 382
Topics: 27
Location: Chennai, India

PostPosted: Thu Mar 13, 2003 11:24 pm    Post subject: Reply with quote

Hi all,

The question by Jashu got me thinking. Even in very small DBMS systems like MS-Access, we have got the option to load a table from a flat file using delimiters. Isn't it odd that in a well established RDBMS like DB2, you do not have the option to load a table using delimiters. Logically, a delimited file should be enough to load into a table without any load card. I, of course do not know whether the same is possible in other popular RDBMS like Oracle or Sybase.

Masters ==> What are your thoughts on this?

Regards,
Manas
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
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