Re: first try at postgres functions
От | Michael Fuhr |
---|---|
Тема | Re: first try at postgres functions |
Дата | |
Msg-id | 20041202052028.GA60838@winnie.fuhr.org обсуждение исходный текст |
Ответ на | first try at postgres functions ("Kevin B." <db@ke5in.com>) |
Список | 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/
В списке pgsql-novice по дате отправления: