MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Eric D. Patterson Date:March 15 1999 11:24pm
Subject:replace problems (ctnd)
View as plain text  
I have been consistantly seeing this problem since upgrading to version

after creating my table, I issue the following command to create a
key (all have already been declared as not null):

ALTER TABLE SerDeal ADD PRIMARY KEY (Serial_No,Model,Dealer)

I then issue 2 replace commands, the first to create (insert) the entry
within the table, the second *should* update the associated data within
that record, as the keys do match up, as you will see later.

(Please note that this is being done through the perl DBI, and looks
kinda' ugly:)

$insertsql = "REPLACE INTO SerDeal
$sth = $dbh->query($insertsql);

Finally, the following select shows that the row does in fact exist
the database twice, not just once, despite the key declarations.  Am I
wrong, or is the following not possible, given that I declared these
fields as the primary key?

select Serial_No,Model,Dealer from SerDeal where Serial_No='67110264'
| Serial_No | Model  | Dealer |
| 67110264  | AF5206 |   1010 |
| 67110264  | AF5206 |   1010 |

I hope that all makes sence to everybody, please let me know if you have
heard of a way to solve this one...
replace problems (ctnd)Eric D. Patterson16 Mar
  • replace problems (ctnd)Michael Widenius16 Mar