I could not understand why you have split into 3 foreign keys in TRANSACTIONS tables pointing to same primary key in PROCEDURES table. And then again 2 AMOUNT columns for 1 in PROCEDURES. I suppose the foreign key columns are declared as NULL. As per me it should be PROCEDURE# single column as foreign key. Also is AMOUNT = TOTAL = AMOUNT#1+ AMOUNT#2 + AMOUNT#3. If this is so then TOTAL column is dangerously redundant with a different name.
You can define BEFORE/AFTER INSERT/UPDATE/DELETE triggers on PROCEDURES table so that when ever one such operation occurs then within the trigger body/definition you will write a calcualted INSERT/UPDATE/DELETE on TRANSACTIONS table. Then again trigger can be FOR EACH ROW (mostly this is the one used) and FOR EACH STATEMENT. The trigger can call a procedure/function(this you can use in queries). The other way round is keep the entire set of operations i.e. let us say INSERT in PROCEDURES and TRANSACTIONS in a single transaction (logical unit of work) on whose completion you will COMMIT else if error rollback the whole thing. You need to set auto-commit false for this.
The third way is keep the entire set of operations in a SQL script or OS embedded SQL file and schedule jobs to execute periodically. This is only if it is this way.
Main Topics
Browse All Topics





by: quincydudePosted on 2009-03-05 at 19:22:30ID: 23813579
Do u mean you want to have some setting like the 'default' thing that once user insert a record with values PROCEDURE#1,2,3 then the db will retrieve the corresponding AMOUNT#1,2,3 from those table for you?
m/oracle/t riggers/af ter_insert .php
I have never heard of such feature but if there's one it would be great.
Oh wait, I think you can achieve the same functionality using trigger.
Use the after insert trigger
http://www.techonthenet.co
Hope this helps.