From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | "Kevin B(dot)" <db(at)ke5in(dot)com> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: first try at postgres functions |
Date: | 2004-12-02 05:20:28 |
Message-ID: | 20041202052028.GA60838@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Wed, Dec 01, 2004 at 11:03:00PM -0500, Kevin B. wrote:
> I'm not sure why this does not work.
>
> create or replace function test1() returns int as '
> return 1;
> ' LANGUAGE 'plpgsql';
>
> select test1();
If something doesn't work then it's helpful to describe what you
expect to happen and what actually does happen. In this case you
were probably expecting the value 1 to be returned, but you got
the following error instead:
ERROR: syntax error at or near "1"
CONTEXT: compile of PL/pgSQL function "test1" near line 1
The function doesn't follow the correct PL/pgSQL structure. See
the PL/pgSQL documentation, especially the "Structure of PL/pgSQL"
section:
http://www.postgresql.org/docs/7.4/static/plpgsql.html
> I also tried this:
>
> create or replace function test1() returns int as '
> select 1;
> ' LANGUAGE 'plpgsql';
That's the correct syntax for an SQL (LANGUAGE sql) function but
not for PL/pgSQL.
http://www.postgresql.org/docs/7.4/static/xfunc-sql.html
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Wimmer | 2004-12-02 07:21:30 | Re: first try at postgres functions |
Previous Message | Kevin B. | 2004-12-02 04:03:00 | first try at postgres functions |