pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andreas Haumer <andreas@xss.co.at>
Cc: pgsql-sql@postgresql.org
Subject: Re: Trigger functions with dynamic SQL
Date: Sat, 24 Jul 2004 11:01:47 -0400
Message-ID: <4370.1090681307@sss.pgh.pa.us> (raw)
In-Reply-To: <410272AD.9010100@xss.co.at>
References: <410272AD.9010100@xss.co.at>

Andreas Haumer <andreas@xss.co.at> writes:
> It seems I would have to use EXECUTE on dynamically constructed
> PL/PGSQL statements in order to have my trigger function recognize
> the parameters given to the trigger in TG_ARGV[]

Yup, that's exactly right.  plpgsql isn't designed for this; it's
designed for situations where it can pre-plan and cache plans for
queries, and dynamically-inserted table and column names would just
break that completely.  So you have to fall back to the mechanisms
for fully general constructed-on-the-fly queries, which work but
are a bit painful to use.

You might want to look at pltcl instead, which is much friendlier
to dynamically generated queries (since that's the only way it
does things).  Of course, if you've never used Tcl there'll be
a bit of a learning curve :-(

			regards, tom lane



view thread (5+ messages)  latest in thread

Message-ID: <4370.1090681307@sss.pgh.pa.us>
Permalink:  ../4370.1090681307@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/4370.1090681307@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, andreas@xss.co.at
  Subject: Re: Trigger functions with dynamic SQL
  In-Reply-To: <4370.1090681307@sss.pgh.pa.us>

* 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