Re: stack depth limit exceeded - Mailing list pgsql-general

From Michael Fuhr
Subject Re: stack depth limit exceeded
Date
Msg-id 20050830034133.GA10762@winnie.fuhr.org
Whole thread Raw
In response to Re: stack depth limit exceeded  (Jamie Deppeler <jamie@doitonce.net.au>)
List 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

pgsql-general by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: PQConnectdb SSL (sslmode): Is this a bug
Next
From: "Matt A."
Date:
Subject: Re: [SQL] question