Variable column name in plpgsql function - Mailing list pgsql-general

From George Woodring
Subject Variable column name in plpgsql function
Date
Msg-id 54D4D0185B2D114A84630606A603DC9219A37E@iglassmail.istructure.com
Whole thread Raw
Responses Re: Variable column name in plpgsql function
List 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

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: [PERFORM] pg_restore taking 4 hours!
Next
From: Jan Wieck
Date:
Subject: Re: Upcoming Changes to News Server ...