If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > How to do data import from a flat file ?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-15-04, 13:29
SamCute SamCute is offline
Registered User
 
Join Date: Mar 2004
Posts: 205
How to do data import from a flat file ?

Hi,

How to load the data from a flat text file having delimiter ',' between columns ?
Please give a sample query.

Thanks,
Sam
Reply With Quote
  #2 (permalink)  
Old 07-15-04, 13:31
J Petruk J Petruk is offline
Registered User
 
Join Date: Mar 2004
Location: Toronto, ON, Canada
Posts: 513
Quote:
Originally Posted by SamCute
Hi,

How to load the data from a flat text file having delimiter ',' between columns ?
Please give a sample query.

Thanks,
Sam
modified by coldel;

See LOAD/IMPORT for dets.
__________________
--
Jonathan Petruk
DB2 Database Consultant
Reply With Quote
  #3 (permalink)  
Old 07-15-04, 13:55
SamCute SamCute is offline
Registered User
 
Join Date: Mar 2004
Posts: 205
Hi,

Thanks for your reply.

Can you give some examples for the same.

Sam.
Reply With Quote
  #4 (permalink)  
Old 07-15-04, 14:05
J Petruk J Petruk is offline
Registered User
 
Join Date: Mar 2004
Location: Toronto, ON, Canada
Posts: 513
There are some in the Command reference...

import from myfile.ixf of ixf messages msg.txt modified by coldel; insert into staff

";" is actually a little tricky since it's a special character to your shell most likely, so stick the command in a file like so:

import from myfile.ixf of ixf messages msg.txt modified by coldel; insert into staff
0

(That's a 0)

and run the command:
db2 -td0 -vf yourfile.sql
__________________
--
Jonathan Petruk
DB2 Database Consultant
Reply With Quote
  #5 (permalink)  
Old 07-15-04, 14:15
SamCute SamCute is offline
Registered User
 
Join Date: Mar 2004
Posts: 205
Hi,

import from myfile.ixf of ixf messages msg.txt modified by coldel; insert into staff

In the above query please explain the following denotes what ?

'of ixf'
'messages'
'modified by coldel'

Then why haven insert into staff ? -- > Is the above is a full single query ?

Thanks,
Sam
Reply With Quote
  #6 (permalink)  
Old 07-15-04, 14:18
J Petruk J Petruk is offline
Registered User
 
Join Date: Mar 2004
Location: Toronto, ON, Canada
Posts: 513
Quote:
Originally Posted by SamCute
Hi,

import from myfile.ixf of ixf messages msg.txt modified by coldel; insert into staff

In the above query please explain the following denotes what ?

'of ixf'
'messages'
'modified by coldel'

Then why haven insert into staff ? -- > Is the above is a full single query ?

Thanks,
Sam
Please look at the IMPORT command in the Command Reference, it explains everything!

I messed up, it should have been:
import from myfile.del of del messages msg.txt modified by coldel; insert into staff

This takes everything from the flat file "myfile.del" which is "of del" (delimited ASCII), writes any messages to msg.txt file, assuming a column delimiter of ";".

Insert is the mode, not an SQL statement.
Staff is the target table.

Command Reference.
__________________
--
Jonathan Petruk
DB2 Database Consultant
Reply With Quote
  #7 (permalink)  
Old 07-15-04, 14:30
dsusendran dsusendran is offline
Registered User
 
Join Date: Apr 2004
Location: Inside Intel
Posts: 165
Post

Reply With Quote
  #8 (permalink)  
Old 01-07-05, 11:41
sleyestone sleyestone is offline
Registered User
 
Join Date: Jan 2005
Posts: 1
alternative methode

hi everyone!

try this sample-statement: instead of using coldel; try coldel0x3B.
by using the hex-code for ";" the problem with the ";" will disappear...

IMPORT FROM "O:\test.txt" OF DEL MODIFIED BY CHARDEL"" COLDEL0x3B DECPT, COMMITCOUNT 100 MESSAGES "O:\test.err" INSERT INTO DB2ADMIN.TEST1;

rgds, sleye.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On