SQL: Trigger Help
Posted on 2014-04-22
I'm working on trying to understand triggers. (I'm basically going through oracles site with my book I bought) I'm trying to learn SQL, because I do it a little on the side with my job. I have an example here that I'm trying to work out.
Basically there are two tables. A invoice table and a customer table. The invoice houses any new invoice information that comes in. The Customer table has a column that states the customer overall balance.
So if a invoice is entered with a new amount, I want that amount to be added to the customer's balance column. Here is what I'm thinking it should be below. but doesn't work sadly:
CREATE OR REPLACE TRIGGER UPDATE_BALANCE
AFTER INSERT OR UPDATE OF INV_AMOUNT ON INVOICE
SET CUST_BAL = CUST_BAL + INV_AMOUNT