PgSQL not recognized

Поиск
Список
Период
Сортировка
От whytwelve13@yahoo.com
Тема PgSQL not recognized
Дата
Msg-id 1163459298.781764.43420@e3g2000cwe.googlegroups.com
обсуждение исходный текст
Ответы Re: PgSQL not recognized  (Martijn van Oosterhout <kleptog@svana.org>)
Re: PgSQL not recognized  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Список pgsql-general
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.

I initiated the default databases, created the postgres user and I
tried to run the following query:

if 1 <> 1 then
   select 1
else
   select 2
end if;

The error was:

ERROR:  syntax error at or near "if" at character 1

I added the language using 'createlang plpgsql', but this didn't help.
This is similar to what I read from

http://www.postgresql.org/docs/8.1/interactive/plpgsql-control-structures.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:

ERROR:  syntax error at or near "if" at character 45

Statements like this are executing normally on other database engines.
I am obviously missing something, probably something specific to
Postgres. I couldn't find anything on the Net or documentation itself
after a few hours search that will give me a hint why this is not
working. Any ideas about this?

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.


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

Предыдущее
От: "surabhi.ahuja"
Дата:
Сообщение: help needed, PG 8.0.0 ERROR: index is not a btree is solved in 8.0.9
Следующее
От: "Kojak"
Дата:
Сообщение: Using PL/pgSQL