pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: jablonov <jablonov@hotmail.com>
To: pgsql-general@postgresql.org
Subject: Re: Trigger Procedure Error: NEW used in query that is not in a rule
Date: Wed, 21 Sep 2011 08:32:04 -0700 (PDT)
Message-ID: <1316619124366-4826781.post@n5.nabble.com> (raw)
In-Reply-To: <86d227fd0708110043q341a2908q67e87570bca89492@mail.gmail.com>
References: <86d227fd0708110043q341a2908q67e87570bca89492@mail.gmail.com>

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-r...
Sent from the PostgreSQL - general mailing list archive at Nabble.com.



view thread (11+ messages)

Message-ID: <1316619124366-4826781.post@n5.nabble.com>
Permalink:  ../1316619124366-4826781.post@n5.nabble.com/
Also on:    postgresql.org/message-id/1316619124366-4826781.post@n5.nabble.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jablonov@hotmail.com, pgsql-general@postgresql.org
  Subject: Re: Trigger Procedure Error: NEW used in query that is not in a rule
  In-Reply-To: <1316619124366-4826781.post@n5.nabble.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox