Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help on load text file to db2

Status
Not open for further replies.

Carney123

Programmer
Apr 11, 2008
15
US
I have a text file which has following format and I want to load into multiple tables in db2.

A,'Abcd',12344,'89','Cad'
B,09122008,04
C,'Unit','Unit Number 3899','Institute',2002-11-10
A,'Cabd',88388,'90','DAC'
B,08112007,03
C,'Unit','Unit Number 3939','Institute',2001-10-05

All A's goes to one table, B goes another and C goes another table.

I wrote a control file in Oracle but I am new to this DB2 and how shall I achieve this. If there is any step by step process that will be really helpful.
 
Thank you for your reply. I want to load this file from stored procedure instead of doing it from control center. Is there any command line? I try to see online help, but no luck. Can you give me any ideas on this.

Thanks again
 
I'd go for the command-line. Google for "IMPORT" or "LOAD". I'm sure it can be done using stored-procedures, but why the <beep> should you, being a novice in DB2?
 
My goal is to load all text file data into temp table and from there Update base tables. This can be easily achivable in Oracle and SQL, I am not familiar in DB2. My client uses DB2, I don't want to be novice in DB2 but it is unfortunate.
 
1. create a table SOURCE with 5 Varchar columns (F1,F2,F3,F4,F4 with length at least 30)
2. load your text file to the new created table, please use "MODIFIED BY COLDEL," only, no character delimiter
3. create table A (4 columns), B (2 columns), C (4 columns)
4. do three INSERT by selecting the SOURCE table, e.g.
INSERT INTO TABLE_A
SELECT F2, F3, F4, F5 FROM SOURCE
WHERE F1 = 'A'

PS1: you can covert the data type in the select statement, for example, get rid of the ' symbol
PS2: in order to make sure those three tables can be linked correctly, you may want add a record id column and the select statement will change to
SELECT ROW_NUMBER() OVER (), F2, F3, F4, F5 FROM SOURCE
WHERE F1 = 'A'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top