Wenn ich die Doku richtig verstehe, befinden sich die alten Werte in
deleted und die neuen in
inserted
SQL-Code:
CREATE TRIGGER `Tabelle_KEEP_UID` BEFORE UPDATE ON Tabelle FOR EACH ROW
BEGIN
DECLARE
@uidval varchar(36);
@uidval2 varchar(36);
@ID ...
select @uidval = deleted.uid from deleted;
select @id = inserted.id, @uidval2 = inserted.uid from inserted;
if (@uidval is null) then
set @uidval = uidval2;
end if
if (@uidval is null) then
set @uidval = lower(UUID());
end if
update Tabelle set uid = @uidval where ID = @ID;
END