LLLLLLL Posted March 17, 2017 Share Posted March 17, 2017 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? Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted March 17, 2017 Share Posted March 17, 2017 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. Quote Link to comment Share on other sites More sharing options...
LLLLLLL Posted March 17, 2017 Author Share Posted March 17, 2017 They are identical. (In fact, I can't set the column to unique right now because the values are duplicate.) You created the trigger in the exact same way, and your Uid was different when inserting two rows? Quote Link to comment Share on other sites More sharing options...
LLLLLLL Posted March 17, 2017 Author Share Posted March 17, 2017 (edited) 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 March 17, 2017 by timneu22 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.