Re: PgSQL not recognized

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: PgSQL not recognized
Date: 2006-11-14 16:30:42
Message-ID: 20061114163042.GA24296@a-kretschmer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

am Mon, dem 13.11.2006, um 15:08:18 -0800 mailte whytwelve13(at)yahoo(dot)com folgendes:
> 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:

There are somethink wrong:

- wrong begin (i use the dollar-quoting-style)
- no 'begin'
- missing ';'
- you want to get a result but defined the function as void

I have rewritten this for you, i hope, this is what you expected:

create function izitest() returns int as $$
begin
if 1 <> 1 then
return 1;
else
return 2;
end if;
end;
$$ language 'plpgsql';

Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47215, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2006-11-14 16:40:58 Re: help needed, PG 8.0.0 ERROR: index is not a btree is solved in 8.0.9
Previous Message Martijn van Oosterhout 2006-11-14 16:27:51 Re: PgSQL not recognized