Re: Trigger Procedure Error: NEW used in query that is not in a rule - Mailing list pgsql-general

From jablonov
Subject Re: Trigger Procedure Error: NEW used in query that is not in a rule
Date
Msg-id 1316619124366-4826781.post@n5.nabble.com
Whole thread Raw
In response to Trigger Procedure Error: NEW used in query that is not in a rule  ("Javier Fonseca V." <fonsecajavier@gmail.com>)
List pgsql-general
Here is other option using functionality of ROW and EXECUTE USING.

  IF EXISTS(SELECT relname FROM pg_class WHERE relname = tablename)
  THEN sql := 'INSERT INTO ' || tablename || ' VALUES (($1).*)';
  ELSE sql := 'INSERT INTO ' || tablexception || ' VALUES (($1).*)';
  END IF;

  tablerow := ROW(NEW.*)::public.measurement;

  EXECUTE sql USING tablerow;

  RETURN new;

--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Trigger-Procedure-Error-NEW-used-in-query-that-is-not-in-a-rule-tp1886197p4826781.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

pgsql-general by date:

Previous
From: Susan Cassidy
Date:
Subject: Re: SQL function and input variables
Next
From: hamann.w@t-online.de
Date:
Subject: looking for a faster way to do that