Re: first try at postgres functions

From: "Robert Wimmer" <seppwimmer(at)hotmail(dot)com>
To: db(at)ke5in(dot)com, pgsql-novice(at)postgresql(dot)org
Subject: Re: first try at postgres functions
Date: 2004-12-02 07:21:30
Message-ID: BAY10-F54F0DDA9691EB11D1F0035D0B00@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

the correct syntax is

CREATE OR REPLACE FUNCTION test1() RETURNS INTEGER AS '
BEGIN
RETURN 1;
END; '
LANGUAGE 'plpgsql';

you have to be aware of different things.

- the syntax of the language itself is a little bit like pascal.
- sometimes the errorcodes are not very helpfull.
- be beware of the quotes. you must quote the "code block" 'BEGIN ....
END;'
- you have to double quote strings inside the block.

there are usefull examples in the docs

>
>Hi,
>I'm not sure why this does not work.
>
>create or replace function test1() returns int as '
> return 1;
>' LANGUAGE 'plpgsql';
>
>select test1();
>
>--------------------------------------------------------
>
>I also tried this:
>
>create or replace function test1() returns int as '
> select 1;
>' LANGUAGE 'plpgsql';
>
>select test1();
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org

_________________________________________________________________
Flexibilität in Ihrem Hotmail-Konto - mehr Möglichkeiten für Ihre E-Mails!
http://join.msn.com/?pgmarket=de-at&DI=1031&XAPID=1581

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Kim Kohen 2004-12-02 10:25:47 Books
Previous Message Michael Fuhr 2004-12-02 05:20:28 Re: first try at postgres functions