On 9/6/2010 9:10 AM, Thorsten Heymann wrote:
No, I think you misunderstood me. I have these keys (in this example)


-          PRIMARY (id)

-          UNIQUE (ip_addr)

-          UNIQUE (print_name)

And when of of the UNIQUEs is duplicated, I'll wshow user a message WHAT key is 
a doublette.


Actually, that was not what you posted above. In your original example you have one primary key and one unique key. That unique key is based on the combination of values {`ip_addr`,`print_name`}. This means that all of these values pairs are unique

'192.168.1.1','queue1'
'192.168.1.1','queue2'
'192.168.2.1','queue1'
'192.168.2.1','queue2'

If I assume that each row was assigned a sequential ID value, then these are rows 1..4 . If I attempted to modify row 1 like this

UPDATE `device` SET `print_name` = 'queue_2' where ID = 1;

Then I would hit a conflict. The combination of

{ip_addr='192.168.1.1', `print_name='queue2'}

already exists in the row where the ID value is 2.

Even if I parsed the error entire message, it would not tell me which element of this UNIQUE key I violated, only that the combination already exists and which constraint is protecting that combination.
--
Shawn Green
MySQL Principal Technical Support Engineer
Oracle USA, Inc.
Office: Blountville, TN

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=arch...@jab.org

Reply via email to