Re: PgSQL not recognized

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: PgSQL not recognized
Дата
Msg-id 20061114162751.GF26120@svana.org
обсуждение исходный текст
Ответ на PgSQL not recognized  ("whytwelve13@yahoo.com" <whytwelve13@yahoo.com>)
Список pgsql-general
On Mon, Nov 13, 2006 at 03:08:18PM -0800, whytwelve13@yahoo.com wrote:
> I just installed a fresh Postgres database. select version(); gives:
>
> "PostgreSQL 8.1.5 on i686-pc-mingw32, compiled by GCC gcc.exe (GCC)
> 3.4.2 (mingw-special)"
>
> Normal statements like select * from sometable work fine.

Have you read the documentation for the creation of functions? And
looked at the examples?

http://www.postgresql.org/docs/8.1/static/plpgsql.html
> I tried using the functions:
>
> create function izitest() returns void as
> 'if 1 <> 1 then
>    select 1
> else
>    select 2
> end if;' language 'plpgsql'
>
> where plpgsql is the name of the language I created. This gave the same
> error:

plpgsql is a language like oracles, you must have a BEGIN/END at least.
There's also the simpler 'sql' language, but it has no IF statement.

BTW, your statement is equivalent to:

SELECT CASE WHEN 1 <> 1 THEN 1 ELSE 2 END;

> Anyway, to pose another question about this. The reason I need the
> above is to check whether the table exists (from
> information_schema.tables) and drop it only in that case (dirty
> exception handling). There might be a way to do it (in 8.1) in another
> way then using ifs to check. The other question still stands, however.

In the latest release, in beta, you can DROP IF EXISTS. However, most
people just execute the drop and ignore the error, less risk of race
conditions.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Вложения

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

Предыдущее
От: Shane Ambler
Дата:
Сообщение: Re: database design ...
Следующее
От: "A. Kretschmer"
Дата:
Сообщение: Re: PgSQL not recognized