Need help with a trigger 
Author Message
 Need help with a trigger


Can someone help me with a trigger.....

Given table invoices with ID, and Total (and bunch of other stuff) and
table Transactions with ID, InvoiceID, UnitCost, and Units where an
consist of one or many Transactions. I want to write a trigger that if
UnitCost or
Units change, then visit all relevant Transactions and compute the new

So I figured I need

create function ComputeInvoiceTotal()
returns OPAQUE as '
begin is where I don't know what to write...
language 'plpgsql';

create trigger transactions_trig after update on transactions
for each row execute procedure ComputeInvoiceTotal

I am a bit confused about parameter passing. Trigger Functions are
supposed to
take no arguments. that means somehow the body of the function will have
to the data. That would be NEW, and OLD special vars (I hope).

And I'm also confused about "for each row". What does it mean/do. I hope
its not
going to visit every row of a given table.  Because the initial
update/insert has
identified which row(s).



Unix Distributed Systems Engineer            HTTP://www.{*filter*}
{*filter*}Shell Engineering

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command

Sat, 24 Jul 2004 14:17:05 GMT
 [ 1 post ] 

 Relevant Pages 

1. Need help with a trigger

2. Need help with update trigger using COLUMNS_UPDATED()

3. Need help writing a trigger

4. Need Help with a Trigger

5. I need help with this trigger

6. Need help with a trigger

7. Need Help with simple Trigger

8. I need help writing a trigger?

9. Need help on a trigger or how to overlay a table field

10. Need help with a trigger

11. Need help with update trigger using COLUMNS_UPDATED()

12. Need help with a trigger on 7.31

Powered by phpBB® Forum Software