After delete trigger problem

From: "Teemu Juntunen" <teemu(dot)juntunen(at)e-ngine(dot)fi>
To: "PostgreSQL" <pgsql-general(at)postgresql(dot)org>
Subject: After delete trigger problem
Date: 2008-11-07 18:57:26
Message-ID: 245949AFD379488D85413B196C3CBA62@eng02
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I have a child table with

CONSTRAINT fkey FOREIGN KEY (x) REFERENCES master (x) MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE.

and

CREATE TRIGGER td_y AFTER DELETE ON chlid FOR EACH ROW EXECUTE PROCEDURE fn_td_y();

and this trigger refers to the master table...

CREATE OR REPLACE FUNCTION fn_td_y() RETURNS trigger AS
$BODY$
DECLARE
fi integer;
BEGIN

SELECT i INTO fi FROM master WHERE x = old.x;
...

It seems that SELECT results to null, so the master has already deleted the row. Is this intended and how can I solve this?

Regards,
Teemu Juntunen

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-11-07 19:23:22 Re: After delete trigger problem
Previous Message Bruno Lavoie 2008-11-07 18:20:27 Re: Importing text file into a TEXT field