jfreak53
05-06-2011, 02:46 PM
So once again in this system that I am converting over they have done something that I see as stupid but I would like to ask some experts. In this one area of the system it is transferring all banking to accounting, the two different systems.
This is the current process between program to database. They insert a bunch of data to temp table1, we will call tt1. Now on tt1 there is a trigger, that on insert of new data checks tt2 to see if the 4 ids with today's date already exist, if so it updates that record from inserted data and adds amount to what's already there. If it doesn't exist then it inserts to tt2 from it's inserted data. Simple trigger.
At the end of the program's sequence it insert's all data in tt2 with the 4 ids and today's date to final table, call it f1. Once done inserting all records with todays date to f1 from tt2, it erases everything in tt1 and tt2.
Now to me this seems like a lot I mean a lot of unnecessary work.
Am I right?
If so what would be better and easier.
Option1:
Run in my PHP script a select query on f1 to see if 4 ids exist with todays date. If so update and add to amount the current value. If not exist insert.
Option2:
Create a procedure to do all of that on f1 then call procedure.
Either way I remove both tt1 and tt2 and cut down time plus remove the stupid trigger and let my DB do less work.
Am I right in my assumption or am I being too naive?
Thanks guys. :thumbsup:
This is the current process between program to database. They insert a bunch of data to temp table1, we will call tt1. Now on tt1 there is a trigger, that on insert of new data checks tt2 to see if the 4 ids with today's date already exist, if so it updates that record from inserted data and adds amount to what's already there. If it doesn't exist then it inserts to tt2 from it's inserted data. Simple trigger.
At the end of the program's sequence it insert's all data in tt2 with the 4 ids and today's date to final table, call it f1. Once done inserting all records with todays date to f1 from tt2, it erases everything in tt1 and tt2.
Now to me this seems like a lot I mean a lot of unnecessary work.
Am I right?
If so what would be better and easier.
Option1:
Run in my PHP script a select query on f1 to see if 4 ids exist with todays date. If so update and add to amount the current value. If not exist insert.
Option2:
Create a procedure to do all of that on f1 then call procedure.
Either way I remove both tt1 and tt2 and cut down time plus remove the stupid trigger and let my DB do less work.
Am I right in my assumption or am I being too naive?
Thanks guys. :thumbsup: