Re: PL/pgSQL Trigger - Variable for shema? Like TG_RELNAME

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: PL/pgSQL Trigger - Variable for shema? Like TG_RELNAME
Date: 2005-10-31 10:46:13
Message-ID: 20051031104613.GA18878@webserv.wug-glas.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

am 31.10.2005, um 10:47:50 +0100 mailte Christian Hofmann folgendes:
> Hello,
>
> while my trigger is fired, I can access the variable "TG_RELNAME" to get the
> name of the table that is updated.
> How will I get the name of the shema this table is stored?

You have the TG_RELNAME:

SELECT nspname FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE c.relname = TG_RELNAME;

>
> Thank you,

Thanks to itsMe_ in #postgresql ;-)
(IRC-Channel)

11:32 < akretschmer> Hi, i have a table-oid and need to know the schema-name. What can i do?
11:43 < itsMe_> akretschmer: SELECT nspname FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE c.relname =
'tablename';

HTH, Andreas
--
Andreas Kretschmer (Kontakt: siehe Header)
Heynitz: 035242/47212, D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
=== Schollglas Unternehmensgruppe ===

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Christian Hofmann 2005-10-31 11:04:17 Re: PL/pgSQL Trigger - Variable for shema? Like TG_RELNAME
Previous Message Christian Hofmann 2005-10-31 09:47:50 PL/pgSQL Trigger - Variable for shema? Like TG_RELNAME