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 > Weird problem in load utility

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-16-09, 06:58
shahnazurs shahnazurs is offline
Registered User
 
Join Date: May 2005
Posts: 25
Weird problem in load utility

I got a flat file like

Code:
3001~"sdsdsdsd'""~200
3002~"abcd"~100
My table emp structure is

Code:
empno integer,
ename varchar(20),
sal integer
If I try executing the following load command

Code:
db2 -x "load from '/export/fring/sample' of del modified by coldel~ replace into emp"
Code:
EMPNO ENAME               SAL
3002    aslamah              100
3001 "sdsdsdsd'"~200      (null)
I am just wondering what went wrong here?

Can somebody please help me.

Thanks.
Reply With Quote
  #2 (permalink)  
Old 07-16-09, 07:21
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
There is no closing double quote in this line:

Code:
3001~"sdsdsdsd'""~200
When the quote is doubled it loses its special meaning as a delimiter and becomes a part of the string. Try the nochardel modifier.
Reply With Quote
  #3 (permalink)  
Old 07-16-09, 08:33
shahnazurs shahnazurs is offline
Registered User
 
Join Date: May 2005
Posts: 25
Thanks so much for this.

but, I can see the table's field content as

Code:
3001~"sdsdsdsd""'~200
instead of

Code:
3001~"sdsdsdsd'""~200
position of single quote has been changed.
Reply With Quote
  #4 (permalink)  
Old 07-16-09, 10:09
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
nochardel will work as Nick stated.
But, quotes and double quotes will be included in loaded data. like this:

load from 'd:\dm_tech\dbforums\load_sample.txt' of del modified by coldel~ nochardel replace into emp

Code:
------------------------------ Commands Entered ------------------------------
SELECT * FROM emp;
------------------------------------------------------------------------------

EMPNO       ENAME                SAL        
----------- -------------------- -----------
       3001 "sdsdsdsd'""                 200
       3002 "abcd"                       100

  2 record(s) selected.
Reply With Quote
  #5 (permalink)  
Old 07-16-09, 10:14
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
If you want to remove quotes and double quotes, you can update the column after loading.
Code:
------------------------------ Commands Entered ------------------------------
UPDATE emp
SET ename = REPLACE(REPLACE(ename, '''', ''), '"', '')
;
------------------------------------------------------------------------------
DB20000I  The SQL command completed successfully.

------------------------------ Commands Entered ------------------------------
SELECT * FROM emp
;
------------------------------------------------------------------------------
SELECT * FROM emp

EMPNO       ENAME                SAL        
----------- -------------------- -----------
       3001 sdsdsdsd                     200
       3002 abcd                         100

  2 record(s) selected.
Reply With Quote
  #6 (permalink)  
Old 07-20-09, 06:11
shahnazurs shahnazurs is offline
Registered User
 
Join Date: May 2005
Posts: 25
Thanks so much, it worked fine.

Is is possible to preserve spaces in a particular field?

1002~ ~100
1003~shahnaz ~200

First record should insert with 3 space for the second field and trailing spaces for second record.

Thanks.
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