Re: trigger troubles

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: James Gregory <james(at)anchor(dot)net(dot)au>
Cc: PostgreSQL general list <pgsql-general(at)postgresql(dot)org>
Subject: Re: trigger troubles
Date: 2003-03-20 05:23:09
Message-ID: 20030319212028.T64355-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 20 Mar 2003, James Gregory wrote:

> On Thu, 2003-03-20 at 04:10, Stephan Szabo wrote:
> > On 20 Mar 2003, James Gregory wrote:
> >
> > > List of functions
> > > Result data type | Schema | Name | Argument data types
> > > ------------------+------------+-------------------+---------------------
> > > text | pg_catalog | format_type | oid, integer
> > > "trigger" | public | foreign_key_check | text
> > > (2 rows)
> > >
> > > perversity=# create trigger f_foreign_key_check before insert or update
> > > on f for each row execute procedure foreign_key_check ('f');
> > > ERROR: CreateTrigger: function foreign_key_check() does not exist
> >
> > Trigger functions should be created to return trigger and take no
> > arguments. The arguments from create trigger are generally passed in
> > a different way (although I don't know what that is for plpython)
>
> It would be sufficient to get the table name from within the python code
> somehow, but I couldn't find a way to do this.
>
> From
> http://www.postgresql.org/docs/view.php?version=7.3&idoc=0&file=plpython-trigger.html
> and
> http://www.postgresql.org/docs/view.php?version=7.3&idoc=0&file=sql-createtrigger.html
>
> it looks very much like I am using the correct syntax. Is this a bug? Is

Your function is defined to take an argument of type text, but trigger
functions must be defined to take no arguments. So you need to make the
function as foreign_key_check() [no args] and it looks like you use
TD["args"][0] to get the argument you're passing at create trigger time.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Bartley 2003-03-20 05:52:18 OID wrap in pg_class
Previous Message Tom Lane 2003-03-20 05:12:45 Re: FIPS 127-2