Re: Passing parameters to triggers - Mailing list pgsql-general

From Doug McNaught
Subject Re: Passing parameters to triggers
Date
Msg-id m3adt3xk5e.fsf@varsoon.denali.to
Whole thread Raw
In response to Passing parameters to triggers  (Hans-Jürgen Schönig <hs@cybertec.at>)
List pgsql-general
Hans-Jürgen Schönig <hs@cybertec.at> writes:

> I have a severe problem when working with PL/pgSQL triggers. Somehow the
> problem seems to be strange. Here is the code:
>
> CREATE OR REPLACE FUNCTION checkint () RETURNS opaque AS
> '
>         BEGIN
>                 IF      TG_OP = ''DELETE'' THEN
>                         RAISE NOTICE ''% wert'', TG_ARGV[0];
>                         DELETE FROM TG_ARGV[0];

You need to construct a query on the fly using EXECUTE, since queries
are preparsed in PL/pgSQL.  So it would be:

EXECUTE ''DELETE FROM '' || TG_ARGV[0] ;

-Doug
--
Doug McNaught       Wireboard Industries      http://www.wireboard.com/

      Custom software development, systems and network consulting.
      Java PostgreSQL Enhydra Python Zope Perl Apache Linux BSD...

pgsql-general by date:

Previous
From: Vincent Stoessel
Date:
Subject: bug/feature with upper function?
Next
From: Neil Conway
Date:
Subject: Re: Notify argument?