Posted by J.O. Aho on 01/09/06 18:02
jj wrote:
> Hi all
>
> All of a sudden I cant alter values in rows where the column is a primary
> key. It just reverts to the old value that was there if I try to make any
> changes.
>
> If I try changing a value on any other (non-primary key) column , it changes
> the data no problem.
Control that the value you change to aren't already in the table
eg table Simple
Id Name
A Carl
B Buddy
C Cheng
D David
E Earl
ID is the primary key.
UPDATE Simple SET Id='C' WHERE Id='A';
This will fail as there already is a row with the Id=C (Cheng) and with the
primary key there is only allowed to be one of each.
While the Name isn't a primary key, you could do
UPDATE Simple SET Name='Cheng' WHERE Id='A';
As there aren't any restrictions.
//Aho
[Back to original message]
|