From: | Oliver Elphick <olly(at)bray-healthcare(dot)com> |
---|---|
To: | Andrus <eetasoft(at)online(dot)ee> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: How to determine table schema in trigger function |
Date: | 2005-08-18 14:47:43 |
Message-ID: | 1124376463.12407.5.camel@localhost.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, 2005-08-18 at 17:02 +0300, Andrus wrote:
> 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 ?
How about extracting relnamespace from pg_catalog.pg_class?
UPDATE serverti SET lastchange='now'
WHERE tablename=TG_RELNAME and schemaname=(
SELECT n.nspname
FROM pg_catalog.pg_namespace AS n,
pg_catalog.pg_class AS c
WHERE c.relnamespace = n.oid AND
c.oid = TG_RELID
);
From | Date | Subject | |
---|---|---|---|
Next Message | Alexandre Barros | 2005-08-18 15:43:49 | Re: PostgreSQL 8.0.3 limiting max_connections to 64 ? |
Previous Message | Robert Treat | 2005-08-18 14:43:36 | Re: [GENERAL] pgsql-bugs |