Re: first try at postgres functions - Mailing list pgsql-novice

From Robert Wimmer
Subject Re: first try at postgres functions
Date
Msg-id BAY10-F54F0DDA9691EB11D1F0035D0B00@phx.gbl
Whole thread Raw
In response to first try at postgres functions  ("Kevin B." <db@ke5in.com>)
List 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


pgsql-novice by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: Books
Next
From: "Hari Bhanujan"
Date:
Subject: Re: Books