Re: Using the NEW record in an EXECUTE command in a PL/pgSQL trigger function

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Ali Pouya <alipouya2(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Using the NEW record in an EXECUTE command in a PL/pgSQL trigger function
Date: 2013-01-02 13:27:01
Message-ID: CAFj8pRBDVsZWZ77hXLGsLWXSj0Ew_S41=5n9Mynf_Xw9b6dyjA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello

2013/1/2 Ali Pouya <alipouya2(at)gmail(dot)com>:
> Hi all,
>
> The SQL file joined here reproduces the simplified version of a problem that
> I encounter when trying to use the "NEW" record in an EXECUTE command within
> a PL/PgSql trigger function.
>
> In this script the commented INSERT command works fine but the EXECUTE
> commande returns the following error message :
>
> ERROR: missing FROM-clause entry for table "new"

you forgot USING clause

BEGIN
EXECUTE 'INSERT INTO measurement1 values(new.*)' USING new;
-- INSERT INTO measurement1 values(new.*);
RETURN NULL;
END;

Regards

Pavel Stehule

>
> I also tried other versions, some of them with the USING clause without
> success.
>
> My aim is to write a generic trigger function ignoring the column names and
> types of the triggering table for partitionning purposes.
>
> Can somebody help me ?
> Thanks a lot
> Best Regards
> Ali
>
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ali Pouya 2013-01-02 13:53:32 Re: Using the NEW record in an EXECUTE command in a PL/pgSQL trigger function
Previous Message Ali Pouya 2013-01-02 12:49:09 Using the NEW record in an EXECUTE command in a PL/pgSQL trigger function