How to determine table schema in trigger function

From: "Andrus" <eetasoft(at)online(dot)ee>
To: pgsql-general(at)postgresql(dot)org
Subject: How to determine table schema in trigger function
Date: 2005-08-18 14:02:58
Message-ID: de24k1$7ke$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I created generic (for tables in different schemas) trigger function :

CREATE OR REPLACE FUNCTION setlastchange() RETURNS "trigger"
AS $$BEGIN
UPDATE serverti SET lastchange='now' WHERE tablename=TG_RELNAME and
schemaname=TG_SCHEMA;
RETURN NULL;
END$$ LANGUAGE plpgsql STRICT;

Unfortunately, this does not work since TG_SCHEMA is not valid in PL/pgSQL

How to determine schema name where table TG_RELNAME belongs in trigger
function ?

Andrus.

table structure is:

CREATE TABLE serverti (
schemaname CHARACTER(7),
tablename CHARACTER(8) ,
lastchange timestamp,
primary key (schemaname, tablename) );

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Fuhr 2005-08-18 14:05:14 Re: Same database, different query plans
Previous Message Michel Bouchard 2005-08-18 13:29:03