Re: [SQL] Referencing external table in update/insert triggers

2010-02-18 Thread Amitabh Kant
On Thu, Feb 18, 2010 at 2:53 PM, Richard Huxton wrote: > On 17/02/10 15:18, Amitabh Kant wrote: > >> >> CREATE OR REPLACE FUNCTION update_data() RETURNS TRIGGER AS $update_data$ >> BEGIN >> IF NEW.t1f4> t2.t2f4 >> UPDATE t2 set t2f2=NEW.t1f2, t2f3=NEW.t1f3, t2f4=NEW.t1f4 where >> t2f

Re: [SQL] Referencing external table in update/insert triggers

2010-02-18 Thread Richard Huxton
On 17/02/10 15:18, Amitabh Kant wrote: CREATE OR REPLACE FUNCTION update_data() RETURNS TRIGGER AS $update_data$ BEGIN IF NEW.t1f4> t2.t2f4 UPDATE t2 set t2f2=NEW.t1f2, t2f3=NEW.t1f3, t2f4=NEW.t1f4 where t2f1=NEW.d1; RETURN NEW; END IF; END; $update_data$ LANGUAGE pl

[SQL] Referencing external table in update/insert triggers

2010-02-17 Thread Amitabh Kant
Hi I have the following table structure for which I am trying to set a AFTER INSERT or UPDATE trigger: CREATE OR REPLACE FUNCTION update_data() RETURNS TRIGGER AS $update_data$ BEGIN IF NEW.t1f4 > t2.t2f4 UPDATE t2 set t2f2=NEW.t1f2, t2f3=NEW.t1f3, t2f4=NEW.t1f4 where t2f1=NEW.d1;