Re: Stored Proc Problem

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Landrum <rlandrum(at)aol(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Stored Proc Problem
Date: 2007-07-31 04:09:20
Message-ID: 6236.1185854960@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Robert Landrum <rlandrum(at)aol(dot)net> writes:
> I'm writing a stored procedure that will execute as a trigger.
> Arguments being passed to the procedure are field names.

> My goal is to convert those field names into the field values. However,
> I've not been successful. I thought that the following should have worked.

> EXECUTE ''field_val := NEW.''||tg_argv[1]||'';'';

> Nor does

> EXECUTE ''SELECT INTO field_val NEW.''||tg_argv[1]||'';'';

> I've tried using open for execute too... No luck.

> Is this possible in pure SQL?

Well, that's not "pure SQL", it's plpgsql ... but the answer is no.
plpgsql can't deal with selection of run-time-specified fields from
its variables. You'd have better luck coding this in one of the other
PL languages.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ronald Rojas 2007-07-31 04:19:47 alter table table add column
Previous Message Tony Caduto 2007-07-31 04:01:55 Re: The leanest, meanest Windows installer possible