Re: How to check if a table exists from functions.

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: How to check if a table exists from functions.
Дата
Msg-id Pine.BSF.4.21.0106201421270.99731-100000@megazone23.bigpanda.com
обсуждение исходный текст
Ответ на How to check if a table exists from functions.  (mikael.kjellstrom@_no_spam_flygtaxi.se (Mikael Kjellström))
Список pgsql-sql
On Tue, 19 Jun 2001, Mikael Kjellstr�m wrote:

> 
> Maybe I am doing this the wrong way, but how do I check if a table exist?
> 
> This works from psql:
> 
> select
>   relname
> from
>   pg_class
> where
>   relname = 'tablename'
> 
> 
> But if I try to do the same from a PL/PGSQL stored procedure I get the 
> following error message:
> 
> ERROR:  unexpected SELECT query in exec_stmt_execsql()
> 
> Isn't select's allowed from stored procedures?

You'll want to use something like:
declarefoo name;
begin...select relname INTO foo from pg_class whererelname=''tablename'';...
end;




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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: Using the extract() function in plpgsql
Следующее
От: clayton cottingham
Дата:
Сообщение: commentds on redhats new database