Re: [GENERAL] Question of using trigger's OLD in EXECUTE

2009-10-23 Thread Nim Li
Thank you Sam!! The code in the posting solves my issue. :) Nim On 10/23/2009 12:07 PM, Sam Mason wrote: On Fri, Oct 23, 2009 at 11:27:11AM -0400, Nim Li wrote: CREATE OR REPLACE FUNCTION cp_tbl() RETURNS TRIGGER AS $proc$ BEGIN EXECUTE 'INSERT INTO ' || TG_ARGV[0]

Re: [GENERAL] Question of using trigger's OLD in EXECUTE

2009-10-23 Thread Sam Mason
On Fri, Oct 23, 2009 at 11:27:11AM -0400, Nim Li wrote: > CREATE OR REPLACE FUNCTION cp_tbl() RETURNS TRIGGER AS $proc$ >BEGIN > EXECUTE 'INSERT INTO ' || > TG_ARGV[0] || > ' SELECT ' || > OLD; > RETURN NEW; >END; > $proc$ LANGUAG

[GENERAL] Question of using trigger's OLD in EXECUTE

2009-10-23 Thread Nim Li
Hello, I'm new to PostgreSQL and wonder if anyone can help. I'm creating an after-update-trigger for all tables, which copy the old records to a backup table. In my test, the table with this trigger has only two columns - one BIGINT and one VARCHAR. Also I'd like to pass the backup table's