Обсуждение: was field updated

Поиск
Список
Период
Сортировка

was field updated

От
Sim Zacks
Дата:
I need to know if a field was updated in an update statement, even if it
was updated to the same value that it already contained.

Basically, I want the field to be automatically set to null if the
update statement didn't manually set it to something.


I could not figure out how to do this with a trigger or rules, as if the
value was populated before the update statement, it will be in both the
new and the old structures.


My only thought is to have a trigger change the value that is updated
and then if it is the same value in the new and the old then I know that
it was not updated, but that is uglier then I would like.


Any thoughts?


Re: was field updated

От
Sim Zacks
Дата:
> I don't get it,
> you mean even if the field contain some data, it would be set to null
> if your update statement do not update the field?
Exactly. In my example, I have a record that shows current status and
can be updated by multiple processes. The only thing that is relevant
when I look at it is the last update. If process 1 updates fields A, B
and C and process 2 only updates fields A and B, then I want to set C to
null so that when I look at the current status, I see what the last
status that was set is.
I also don't have the ability to change all the other processes, so that
they set fields that they are not using to null.

In MSSQL triggers there is an UPDATE function that tells you if this
column was set in the update statement. I am looking for similar
functionality.

Sim