I have a procedure that updates a field in a table as part of an open cursor, looping through rows and updating an error_code field. Only after the cursor runs out does it issue a commit statment.
I am thinking of adding a before update trigger to the target table so that any rows flagged in the procedure are automatically passed to an exception table which in turn fires a trigger that deletes back on the pk. In this way rows flagged as not null on the target table never remain on the target table.
The question is if all these updates are part of a cursor then there will be loads of updates that have not committed on the target table. Will the before update trigger fire as each prior-to-commit row is updated on the target table or will it fire when the commit is issued at the end of the cursor on the commit.
If it's the latter ( which I think it is due to data consistency ) does the trigger fire for each row that has been updated on the commit on a row by row basis. Does this even matter? I could call a separate procedure to do this if it is a problem. Would it be better to use an after update trigger instead?
Any advise would be appreciated.
cheers
simmo
I am thinking of adding a before update trigger to the target table so that any rows flagged in the procedure are automatically passed to an exception table which in turn fires a trigger that deletes back on the pk. In this way rows flagged as not null on the target table never remain on the target table.
The question is if all these updates are part of a cursor then there will be loads of updates that have not committed on the target table. Will the before update trigger fire as each prior-to-commit row is updated on the target table or will it fire when the commit is issued at the end of the cursor on the commit.
If it's the latter ( which I think it is due to data consistency ) does the trigger fire for each row that has been updated on the commit on a row by row basis. Does this even matter? I could call a separate procedure to do this if it is a problem. Would it be better to use an after update trigger instead?
Any advise would be appreciated.
cheers
simmo