follow up RE: Trigger with delete

From: Marc Britten <mbritten(at)cybernet-usa(dot)com>
To: "'Matthias Teege'" <matthias(at)mteege(dot)de>, pgsql-general(at)postgresql(dot)org
Subject: follow up RE: Trigger with delete
Date: 2000-06-20 15:20:30
Message-ID: ABFF67479EC9D111AFA30060B01AACDA03ADF696@mail
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

you need to enable plpgsql AND use it as the lang of your function so
LANGUAGE 'plpgsql';

thanks

-----Original Message-----
From: Marc Britten
Sent: Tuesday, June 20, 2000 10:11 AM
To: 'Matthias Teege'; pgsql-general(at)postgresql(dot)org
Subject: RE: [GENERAL] Trigger with delete

2 things

one, you need to enable plpgsql as a lang
see
http://www.postgresql.org/docs/programmer/xplang.htm#XPLANG-TITLE
for details

two , triggers need to call functions that return 'opaque'. so after delete
add return NEW;

-----Original Message-----
From: Matthias Teege [mailto:matthias(at)mteege(dot)de]
Sent: Tuesday, June 20, 2000 8:07 AM
To: pgsql-general(at)postgresql(dot)org
Subject: [GENERAL] Trigger with delete

Moin,

I want to setup a trigger that removes entries from a
related table depented an the record in the main table. So
I try the following:

CREATE FUNCTION "delete_aufpos" (int4) RETURNS int AS '
delete from subtable where key = $1'
LANGUAGE 'SQL';

CREATE TRIGGER delete_auftrag
BEFORE DELETE ON maintable FOR EACH ROW
EXECUTE PROCEDURE delete_aufpos(1);

The create function gives me the following message:

ERROR: function declared to return type int4, but final
query is not a retrieve

What is the return type of 'delete'?
How can I pass the key from the main table to the sub table?

Vielen Dank
Matthias

Browse pgsql-general by date

  From Date Subject
Next Message Steve Wolfe 2000-06-20 17:55:18 Re: Backend died while dropping index
Previous Message Marc Britten 2000-06-20 15:10:58 RE: Trigger with delete