Ok, I'm in trigger hell and my brain has completely shut down.
The situation: we are in the middle of replacing one web site with a rebranded one. The new site, in addition to having a new name and new look, is improving some things about the way we were currenlty doing business. Both sites will be operating simulatneously for about a month. My problem is that my new boss changed how we store customer information and thus we created new tables which are not exact matches for the old tables. We have to leave the old ones in place or the old site will break. We also have a requirement that a customer should be able to log in to either site if he registers on one and he should, of course, be able to see all the transactions done on either site or make changes to his customer profile which would reflect on either site.
Now I have to write triggers on a group of tables that have customer data. So an insert or delete or update on the tables that store the old sites's data will trigger and insert, update, or delete on the new tables and vice versa. I'm sure you can already see where this is a problem. So I get into a recursive situation and immediately get an error message saying I've hit the limit on the number of nested triggers I can hit. Now I figured out that if I set a field with a flag on it that tells me if the record came from a trigger or a regular insert ro update, that it would stop recursing and work fine. This is fine for the inserts and the initial update and the delete. However, what happens the second time the customer wants to update the record? It is already flagged as being changed by a trigger from the first update so now the trigger won't fire at all for the second real update. So what do I do to get the data back into a state where it the trigger can fire again?
Does any of this makes sense or am I babbling incoherently?
The situation: we are in the middle of replacing one web site with a rebranded one. The new site, in addition to having a new name and new look, is improving some things about the way we were currenlty doing business. Both sites will be operating simulatneously for about a month. My problem is that my new boss changed how we store customer information and thus we created new tables which are not exact matches for the old tables. We have to leave the old ones in place or the old site will break. We also have a requirement that a customer should be able to log in to either site if he registers on one and he should, of course, be able to see all the transactions done on either site or make changes to his customer profile which would reflect on either site.
Now I have to write triggers on a group of tables that have customer data. So an insert or delete or update on the tables that store the old sites's data will trigger and insert, update, or delete on the new tables and vice versa. I'm sure you can already see where this is a problem. So I get into a recursive situation and immediately get an error message saying I've hit the limit on the number of nested triggers I can hit. Now I figured out that if I set a field with a flag on it that tells me if the record came from a trigger or a regular insert ro update, that it would stop recursing and work fine. This is fine for the inserts and the initial update and the delete. However, what happens the second time the customer wants to update the record? It is already flagged as being changed by a trigger from the first update so now the trigger won't fire at all for the second real update. So what do I do to get the data back into a state where it the trigger can fire again?
Does any of this makes sense or am I babbling incoherently?