Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 52FD9475876 for ; Wed, 24 Jul 2002 14:26:00 -0400 (EDT) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 3.5.9) with ESMTP id 1588538; Wed, 24 Jul 2002 11:25:59 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Wim , pgsql-sql@postgresql.org Subject: Re: Trying to write a function... Date: Wed, 24 Jul 2002 11:26:27 -0700 X-Mailer: KMail [version 1.4] References: <3D3EFBB1.9040904@belbone.be> In-Reply-To: <3D3EFBB1.9040904@belbone.be> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200207241126.27263.josh@agliodbs.com> X-Archive-Number: 200207/392 X-Sequence-Number: 8770 Wim, > CREATE FUNCTION f_addrtr (varchar(16),varchar(32)) RETURNS bool AS ' > DECLARE > index int4; > BEGIN > index :=3D 'nextval('s_routerid')'; > INSERT INTO t_routers VALUES (index, $1, $2); > RETURN 1; > END;' > LANGUAGE 'plpgsql'; >=20 > What am I doing wrong? Bad quotes, bad data type usage. Change as follows: CREATE FUNCTION f_addrtr (varchar(16),varchar(32)) RETURNS bool AS ' DECLARE index int4; BEGIN index :=3D nextval(''s_routerid''); INSERT INTO t_routers VALUES (index, $1, $2); RETURN TRUE; END;' LANGUAGE 'plpgsql'; --=20 -Josh Berkus Aglio Database Solutions San Francisco