Re: PL/pgSQL Trigger - Variable for shema? Like TG_RELNAME - Mailing list pgsql-novice

From Christian Hofmann
Subject Re: PL/pgSQL Trigger - Variable for shema? Like TG_RELNAME
Date
Msg-id 012901c5de0a$d69efcb0$7b00a8c0@CHRISSI
Whole thread Raw
In response to Re: PL/pgSQL Trigger - Variable for shema? Like TG_RELNAME  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Responses Re: PL/pgSQL Trigger - Variable for shema? Like TG_RELNAME  (Michael Fuhr <mike@fuhr.org>)
List pgsql-novice
Hello Anreas,

> 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. But when I habe more than one table in different shemas with the
same name?

> 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';

Yes, I will take the table-oid to get the shema name. Thats a better idea.

I thought there were a variable the shema is stored in. So I need an extra
query.

But it is ok.

Thank you,

Christian


pgsql-novice by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: PL/pgSQL Trigger - Variable for shema? Like TG_RELNAME
Next
From: Michael Fuhr
Date:
Subject: Re: PL/pgSQL Trigger - Variable for shema? Like TG_RELNAME