PgSQL not recognized

From: "whytwelve13(at)yahoo(dot)com" <whytwelve13(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: PgSQL not recognized
Date: 2006-11-13 23:08:18
Message-ID: 1163459298.781764.43420@e3g2000cwe.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Igor Shevchenko 2006-11-14 00:23:39 can't start postgresql
Previous Message Daniel Verite 2006-11-13 23:01:44 Re: encoding advice requested