Re: PROBLEM WITH FUNCTIONS IN POSTGRES

From: "Victor Yegorov" <viy(at)pirmabanka(dot)lv>
To: "Mario Alberto Soto Cordones" <mario_soto(at)compuall(dot)cl>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: PROBLEM WITH FUNCTIONS IN POSTGRES
Date: 2003-03-20 17:22:42
Message-ID: 20030320172242.GA20481@pirmabanka.lv
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

* Mario Alberto Soto Cordones <mario_soto(at)compuall(dot)cl> [20.03.2003 19:09]:
> Hi...
>
> i create a function in postgres to return a data of a table but when try
> to create say
>
> PostgreSQL ha dicho: ERROR: parser: parse error at or near "text"
> Your query:
>
> CREATE FUNCTION sinomemp(text)
> RETURNS text
> AS 'DECLARE sinomemp TEXT;
> BEGIN
> SELECT name
> FROM simaemp
> WHERE cod = $1;
> RETURN sinomemp;
> END;'
> LANGUAGE 'sql'

Actually, this question is for SQL list, not ADMIN.

You have `return' statement in your code, it is part of plpgsql language,
not sql.
So, changing last line to:

LANGUAGE plpgsql;

will solve your problem.

One note: it seems, that sinomemp variable is not in use.

May be this is what you need:

CREATE or replace FUNCTION sinomemp(text) RETURNS text AS '
SELECT name
FROM simaemp
WHERE cod = $1;'

LANGUAGE sql;

--

Victor Yegorov

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Andrew Biagioni 2003-03-20 18:40:42 Re: Performance problems with Postgresql
Previous Message Mario Alberto Soto Cordones 2003-03-20 17:07:29 PROBLEM WITH FUNCTIONS IN POSTGRES