Variable column name in plpgsql function

From: "George Woodring" <george(dot)woodring(at)iglass(dot)net>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Variable column name in plpgsql function
Date: 2004-12-01 16:44:16
Message-ID: 54D4D0185B2D114A84630606A603DC9219A37E@iglassmail.istructure.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am trying to create a trigger that needs to capture the primary key
value out of NEW variable.

However the trigger can be called from 2 different tables whose PKs are

Table1id
Table2id

Is possible to declare a variable to build the column name

Tableid varchar(20) := TG_RELNAME || ''id'';

And then use this variable to get the PK value?

Tableidvalue int4 := NEW.tableid;

Thanks,
Woody

----------------------------------------
iGLASS Networks
211-A S. Salem St
Apex NC 27502
(919) 387-3550 x813
www.iglass.net

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jan Wieck 2004-12-01 17:07:12 Re: Upcoming Changes to News Server ...
Previous Message Tom Lane 2004-12-01 15:38:37 Re: [PERFORM] pg_restore taking 4 hours!