X-Original-To: pgsql-admin@postgresql.org Received: from shield.pirmabanka.lv (unknown [195.114.57.4]) by postgresql.org (Postfix) with ESMTP id 4BACF474E4F for ; Thu, 20 Mar 2003 12:21:45 -0500 (EST) Received: from wall2.pirmabanka.lv (wall2-pub.pirmabanka.lv [195.114.57.14]) by shield.pirmabanka.lv (8.12.8/8.9.3) with SMTP id h2KHLntw024001 for ; Thu, 20 Mar 2003 19:21:49 +0200 Received: from share.pirmabanka.lv ([10.0.0.10]) by wall2.pirmabanka.lv; Thu, 20 Mar 2003 19:21:48 +0200 (EET) Received: from pc311x1.pirmabanka.lv (localhost.localdomain [127.0.0.1]) by pirmabanka.lv (8.11.6/8.11.6) with SMTP id h2KHLmu05053 for ; Thu, 20 Mar 2003 19:21:48 +0200 Received: (qmail 20675 invoked by uid 100); 20 Mar 2003 17:22:42 -0000 Date: Thu, 20 Mar 2003 19:22:42 +0200 From: "Victor Yegorov" To: "Mario Alberto Soto Cordones" Cc: pgsql-admin@postgresql.org Subject: Re: PROBLEM WITH FUNCTIONS IN POSTGRES Message-ID: <20030320172242.GA20481@pirmabanka.lv> Mail-Followup-To: "Mario Alberto Soto Cordones" , pgsql-admin@postgresql.org References: <1454.192.168.1.100.1048180049.squirrel@mail.compuall.cl> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="BOKacYhQ+x31HxR3" Content-Disposition: inline In-Reply-To: <1454.192.168.1.100.1048180049.squirrel@mail.compuall.cl> User-Agent: Mutt/1.4.1i X-Archive-Number: 200303/328 X-Sequence-Number: 7968 --BOKacYhQ+x31HxR3 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Mario Alberto Soto Cordones [20.03.2003 19:09]: > Hi... >=20 > i create a function in postgres to return a data of a table but when try > to create say >=20 > PostgreSQL ha dicho: ERROR: parser: parse error at or near "text" > Your query: >=20 > CREATE FUNCTION sinomemp(text) > RETURNS text > AS 'DECLARE sinomemp TEXT; > BEGIN > SELECT name > FROM simaemp > WHERE cod =3D $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 =3D $1;' LANGUAGE sql; --=20 Victor Yegorov --BOKacYhQ+x31HxR3 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE+efji2RKGLEykUDYRAiReAJ9Apf0LApDYmJcjbGXZl6x6GGfyMwCeIXw1 bZd9fcnhnVOCNHgvf50QUTc= =2YeT -----END PGP SIGNATURE----- --BOKacYhQ+x31HxR3--