I'm having troubles with an insert trigger that is supposed to fix a column in a table:
id - auto increment int
thread_id - int [NULL]
What I want to achieve is to set the thread_id
to id
if it's inserted as NULL. I have failed because:
- using
before insert
trigger still does not have the new value forid
and mysteriously setsthread_id
to 0 - using
after insert - update
trigger throws reasonable exceptioncan't update table because it is already used by the statement
. - you can not add additional auto increment field
What is the solution to this problem?