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.

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to