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 > Newbie has problem on Importing data

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-21-06, 08:15
KeeOn KeeOn is offline
Registered User
 
Join Date: Feb 2006
Posts: 2
Newbie has problem on Importing data

I met a problem to import the data from a text file if the data value starting with space


Content of the data file for import - abc.txt
Line1: ABC~ 123456789~123 <== Contains space at FLD_B
Line2: DEF~0123456789~456

Syntax for the import
db2 IMPORT FROM abc.txt OF DEL MODIFIED BY CHARDEL^ COLDEL~ METHOD P "(1, 2, 3)" MESSAGES abc.msg
"INSERT_UPDATE INTO myschema.tbl1 (FLD_A, FLD_B, FLD_C)"

Result after importing abc.txt into myschema.tbl1
FLD_A FLD_B FLD_C
ABC 123456789 123 <== Space at FLD_B has gone
DEF 0123456789 456

Please help!
Reply With Quote
  #2 (permalink)  
Old 02-21-06, 08:33
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Surprise, surprise!

IMPORT ... MODIFIED BY KEEPBLANKS ...
Reply With Quote
  #3 (permalink)  
Old 02-21-06, 08:33
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
You can use the "keepblanks" file type modifier

http://publib.boulder.ibm.com/infoce...e/r0011045.htm

example :
db2 "import from x.txt of del modified by keepblanks insert into timp"


Cheers
Sathyaram

Quote:
Originally Posted by KeeOn
I met a problem to import the data from a text file if the data value starting with space


Content of the data file for import - abc.txt
Line1: ABC~ 123456789~123 <== Contains space at FLD_B
Line2: DEF~0123456789~456

Syntax for the import
db2 IMPORT FROM abc.txt OF DEL MODIFIED BY CHARDEL^ COLDEL~ METHOD P "(1, 2, 3)" MESSAGES abc.msg
"INSERT_UPDATE INTO myschema.tbl1 (FLD_A, FLD_B, FLD_C)"

Result after importing abc.txt into myschema.tbl1
FLD_A FLD_B FLD_C
ABC 123456789 123 <== Space at FLD_B has gone
DEF 0123456789 456

Please help!
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #4 (permalink)  
Old 02-21-06, 09:00
KeeOn KeeOn is offline
Registered User
 
Join Date: Feb 2006
Posts: 2
Talking

Oh! It works! Thanks you all!
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