Re: PgSQL not recognized

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: "whytwelve13(at)yahoo(dot)com" <whytwelve13(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: PgSQL not recognized
Date: 2006-11-14 16:27:51
Message-ID: 20061114162751.GF26120@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Nov 13, 2006 at 03:08:18PM -0800, whytwelve13(at)yahoo(dot)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(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message A. Kretschmer 2006-11-14 16:30:42 Re: PgSQL not recognized
Previous Message Shane Ambler 2006-11-14 16:24:24 Re: database design ...