Re: stack depth limit exceeded

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Jamie Deppeler <jamie(at)doitonce(dot)net(dot)au>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: stack depth limit exceeded
Date: 2005-08-30 03:41:33
Message-ID: 20050830034133.GA10762@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Aug 29, 2005 at 01:45:32PM +1000, Jamie Deppeler wrote:
>
> CREATE TRIGGER "updateContact" AFTER INSERT OR UPDATE
> ON FOR EACH ROW
> EXECUTE PROCEDURE "contacts"."addContactField"();

Please show the actual commands that you're running; the above fails
with a syntax error because it's missing a table name. Is this
trigger on contacts.person?

> CREATE OR REPLACE FUNCTION "contacts"."addContactField" () RETURNS
> trigger AS
> $body$
> begin
> update contacts.person
> set "contact" = new.firstname
> where person."primary" = new."primary";
> return null;
> end;
> $body$
> LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;

As Tom mentioned, if you want to modify the record being inserted
then simply assign a value to one of NEW's columns and have the
function return NEW. In such a case the function will need to be
called in a BEFORE trigger. See "Triggers" and "Trigger Procedures"
in the documentation for more information:

http://www.postgresql.org/docs/8.0/static/triggers.html
http://www.postgresql.org/docs/8.0/static/plpgsql-trigger.html

--
Michael Fuhr

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bernard 2005-08-30 07:04:52 psql from Linux script
Previous Message Matt A. 2005-08-30 03:38:06 Re: [SQL] question