Jump to content

Recommended Posts

I have a trigger, 

 

CREATE TRIGGER `TRIGGER_SOMETABLE_UID` BEFORE INSERT ON `SOMETABLE`
 FOR EACH ROW SET NEW.Uid = UUID(  )
 
Now, I thought this would fire FOR EACH ROW, but if I'm doing an insert like this...
 
insert into sometable ( col1, col2 )
( select col1, col2 from SOME_OTHER_tABLE )
 
... and that inserts two rows, the result is that Uid in both new rows is identical. This is not the desired behavior. Can you tell me how to get a unique Uid in each row?

the result is that Uid in both new rows is identical.

 

Not on my system.

 

Are you sure that the values are in fact identical, not just similar? You realize that the old UUIDs used by MySQL are mostly deterministic and will only differ in some parts, right? And how does your table even accept identical values? An ID column should be the primary key or at least unique.

In fact, adding the unique constraint does nothing. The trigger STILL adds identical values. Whoa.

 

And now it stopped...?

 

I'm going to do some MySql maintenance or something...

Edited by timneu22
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.