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 > MySQL > Replace - Load Data - Key error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-23-04, 13:20
beatsunique beatsunique is offline
Registered User
 
Join Date: Mar 2004
Posts: 2
Replace - Load Data - Key error

I'm having problems doing a bulk load into MySQL and wonder if anyone has come across this before or can see any obvious mistakes.

The error message I keep getting is... ERROR 1062: Duplicate entry '104574' for key 1.

Surely the replace statement in the bulk load sql should be handling this?

Table Structure:

Publish - TinyInt
ID - Int, Auto-Increment
MUSIC - VARCHAR
WWW_LINK - VARCHAR
SKEY - VARCHAR
MUS - VARCHAR
ANO - Int
ART - VARCHAR
UPD - VARCHAR

PK - ANO
Index - ID,ART
FullText Index - ART


File Structure:

MUSIC|WWW_LINK|SKEY|MUS|ANO|ART|UPD|
Jazz||TRUMBAUE|J|31205|Trumbauer, Frankie TNT|20040206|
Dance||00000002|DANC|85|2 Unlimited|20040121|
Gospel||POPE SIS|GOSP|125228|Pope, Sister Lucy & The Pearly Gates|20040109|
Pop||00000002|POP|103|2-Stroke, Arthur & The Chart Commandos|20040216|


BULK LOAD SQL:

LOAD DATA LOW_PRIORITY INFILE 'mm_spi_art_new.txt'
REPLACE
INTO TABLE artist
FIELDS
TERMINATED BY '|'
LINES
TERMINATED BY '\r\n'
IGNORE 1 LINES
(MUSIC,WWW_LINK,SKEY,MUS,ANO,ART,UPD);
Reply With Quote
  #2 (permalink)  
Old 03-24-04, 15:39
ika ika is offline
Registered User
 
Join Date: Oct 2003
Location: Slovakia
Posts: 482
Re: Replace - Load Data - Key error

Quote:
Originally posted by beatsunique
I'm having problems doing a bulk load into MySQL and wonder if anyone has come across this before or can see any obvious mistakes.

The error message I keep getting is... ERROR 1062: Duplicate entry '104574' for key 1.

Surely the replace statement in the bulk load sql should be handling this?

Table Structure:

Publish - TinyInt
ID - Int, Auto-Increment
MUSIC - VARCHAR
WWW_LINK - VARCHAR
SKEY - VARCHAR
MUS - VARCHAR
ANO - Int
ART - VARCHAR
UPD - VARCHAR

PK - ANO
Index - ID,ART
FullText Index - ART


File Structure:

MUSIC|WWW_LINK|SKEY|MUS|ANO|ART|UPD|
Jazz||TRUMBAUE|J|31205|Trumbauer, Frankie TNT|20040206|
Dance||00000002|DANC|85|2 Unlimited|20040121|
Gospel||POPE SIS|GOSP|125228|Pope, Sister Lucy & The Pearly Gates|20040109|
Pop||00000002|POP|103|2-Stroke, Arthur & The Chart Commandos|20040216|


BULK LOAD SQL:

LOAD DATA LOW_PRIORITY INFILE 'mm_spi_art_new.txt'
REPLACE
INTO TABLE artist
FIELDS
TERMINATED BY '|'
LINES
TERMINATED BY '\r\n'
IGNORE 1 LINES
(MUSIC,WWW_LINK,SKEY,MUS,ANO,ART,UPD);
It seems you try insert duplicate entry to the column which is used as primary key or there is unique index on that column
Reply With Quote
  #3 (permalink)  
Old 03-25-04, 04:21
beatsunique beatsunique is offline
Registered User
 
Join Date: Mar 2004
Posts: 2
Thing is that that the mysql docs says this:

If you specify REPLACE, input rows replace existing rows (in other words rows that have the same value for a primary or unique index as an existing row).

You would think that it would work....
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