Triggers - need help !!!

Lists: pgsql-sql
From: "Pradeepkumar, Pyatalo (IE10)" <Pradeepkumar(dot)Pyatalo(at)honeywell(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Triggers - need help !!!
Date: 2004-07-07 06:45:29
Message-ID: 77ED2BF75D59D1439F90412CC5B109740E88BEC1@ie10-sahara.hiso.honeywell.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql


Hi,

I am writing some triggers for my project.
I am writing a trigger on a table after delete....I want to know how u refer
to the row that is being deleted.

For example for a trigger function after INSERT/UPDATE u refer to the row
being inserted/updated using NEW like this....

CREATE FUNCTION .....
BEGIN
IF UPDATE(CreateTime) THEN
SELECT INTO ValidCount COUNT(*) FROM PointTable
WHERE NEW.PointId = PointTable.PointId;
END IF;

......
....
END ;
' LANGUAGE 'plpgsql';

My question is how will refer to the row being deleted in the trigger
function.\
I want to do something like this

DELETE PointTable FROM PointTable
WHERE PointTable.PointId = DELETED.PointId;

Pls help me with this.

> With Best Regards
> Pradeep Kumar P J
>


From: Tomasz Myrta <jasiek(at)klaster(dot)net>
To: "Pradeepkumar, Pyatalo (IE10)" <Pradeepkumar(dot)Pyatalo(at)honeywell(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Triggers - need help !!!
Date: 2004-07-07 07:20:26
Message-ID: 40EBA43A.4070802@klaster.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

On 2004-07-07 08:45, Użytkownik Pradeepkumar, Pyatalo (IE10) napisał:
> Hi,
>
> I am writing some triggers for my project.
> I am writing a trigger on a table after delete....I want to know how u refer
> to the row that is being deleted.
>
> For example for a trigger function after INSERT/UPDATE u refer to the row
> being inserted/updated using NEW like this....

Use OLD instead of NEW.
You can also use OLD inside UPDATE triggers - you have access to row
before update.

Regards,
Tomasz Myrta