Re: TRIGGER Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 27, 2021 at 9:31 PM sbob <sbob@xxxxxxxxxxxxxxxxxxxxx> wrote:
I want to create a trigger function that can set a value for a column if
the column was not specified in the update statement.
[...]

However if the row to be updated already has a value for last_updated_by
even if the last_updated_by column is not specified in the update
statement, then the "IF NEW.last_updated_by IS NULL THEN" is never fired..


Thoughts?

Not specifying a column in an update is shorthand for "leave the column unchanged".  There isn't a way for you to make it mean something else - you only get to see that OLD and NEW are equal.

Thus, your requirement is not possible as described.  And if you have to allow for arbitrary update commands your requirement is going to be impossible to enforce.  Otherwise, you could make all updates go through procedures/functions and enforce the requirement there.

David J.


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux