Re: Check if table or View exists

Поиск
Список
Период
Сортировка
От Jorge Godoy
Тема Re: Check if table or View exists
Дата
Msg-id 200804010013.43596.jgodoy@gmail.com
обсуждение исходный текст
Ответ на Check if table or View exists  ("Jeff Williams" <jeff.williams@hardsoft.com.au>)
Список pgsql-general
Em Monday 31 March 2008 22:35:01 Jeff Williams escreveu:
> I am developing an application where I will have a default table and/or
> view for a select statement for my application.  If a client has a special
> requirement I would like to have a alternate table of the same name in a
> different schema with the change structure.
>
> Schema A
>    Default table - coretable.foo
>
> Schema B
>    Client specific table client.foo
>
> How can I check if a table or alternate view exists in schema B.
>
> ie
>
> if client.foo exists // check for a view or table
>   // my code will use client.foo table
> else
>   // my code will use coretable.foo
> endif
>
> Also is it possible to check via function/via in postgress and not have to
> rely on my application to do the check.  If so how.

I'd give both the same name and make the client schema first in the search
path.  Then, you should just call the function and it would follow the search
path order and give you what you want without having to check anything.

--
Jorge Godoy      <jgodoy@gmail.com>


В списке pgsql-general по дате отправления:

Предыдущее
От: Clemens Schwaighofer
Дата:
Сообщение: Re: Survey: renaming/removing script binaries (createdb, createuser...)
Следующее
От: "F. Jovan Jester"
Дата:
Сообщение: Re: Survey: renaming/removing script binaries (createdb, createuser...)