Use of triggers for selective updates
Posted in 1994
I'm faced with the following problem : I have an update-statement with the potential of changing multiple rows. I would like to use a trigger which would check some constraint for each row that is updated, and roll back/undo the changes if the constraint is not fulfilled, and this on a row by row basis; so, all rows satisfying the specified constraint should be updated and the others left unchanged. I tried calling a stored procedure, raising an exception from within the "for each row ..." triggered action, but this causes the whole triggering (update) statement to be rolled back. I also tried to undo the changes by means of the "inverse" update statement, but this failed because of the restriction that the triggerd statement can not reference the triggering table, except when both statements are updates on mutually exclusive columns. (In fact, I already sent a question concerning this restriction to this newsgroup some time ago). Of course I could use a cursor for update to solve this problem but I really wonder whether or not triggers can do the job, and if so, how ? (in fact, I think what I need is to nest transactions in some way) -- ----------------------------------------------------------- Ria Vandenberghe Ria.Vandenberghe@rug.ac.be UNIVERSITY OF GHENT (BELGIUM) - Computer Science Laboratory Technologiepark-Zwijnaarde 9, B-9052 ZWIJNAARDE, BELGIUM tel: +32/9/264.55.10 fax: +32/9/264.58.42