Re: Conditional Statement

Поиск
Список
Период
Сортировка
От Medi Montaseri
Тема Re: Conditional Statement
Дата
Msg-id 3C82E994.8CF6DDD9@cybershell.com
обсуждение исходный текст
Ответ на Conditional Statement  (Samik Raychauhduri <samik@cae.wisc.edu>)
Список pgsql-general
PG's PL/pgSQL language does indeed support conditional statements.
See PostgreSQL 7.x Programmer's Guide, Procedural Languages, Description
section with your installation.

In fact it supports

IF-THEN
IF-THEN-ELSE
IF-THEN-ELSE IF

However, what I have seen people do in a case of just drop-create is to
simply
drop table; create table. So if the table is not there, you just get an
error.
But your request is valid, what if one wants a better control of what to
create
and what to leave alone.

I think the standard front end (psql(1)) does understand SQL but I'm not
sure
if it also understand PL/pgSQL...perhaps someone can add to this....

Samik Raychauhduri wrote:

> Hello,
> I am trying to write a piece of SQL code, which will first check if a
> table exist, drop it and then recreate it. I didn't see any 'IF' syntax
> in pgsql. Is there any other alternative? I tried to use 'case'
> structure, but didn't succeed.
> Thanks and regards.
> -Samik
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

--
-------------------------------------------------------------------------
Medi Montaseri                               medi@CyberShell.com
Unix Distributed Systems Engineer            HTTP://www.CyberShell.com
CyberShell Engineering
-------------------------------------------------------------------------




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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: April 1
Следующее
От: Samik Raychaudhuri
Дата:
Сообщение: Re: Conditional Statement