Received: from bologna.nettuno.it (bologna.nettuno.it [193.43.2.1]) by hub.org (8.9.3/8.9.3) with ESMTP id JAA21398 for ; Thu, 24 Jun 1999 09:08:50 -0400 (EDT) (envelope-from jose@sferacarta.com) Received: from proxy.sferacarta.com (mail@sfcabop1.nettuno.it [193.207.10.213]) by bologna.nettuno.it (8.8.6/8.8.8/NETTuno 3.2) with ESMTP id PAA21739; Thu, 24 Jun 1999 15:08:24 +0200 (MDT) Received: from rosso.sferacarta.com (sferacarta.com) [10.20.30.5] by proxy.sferacarta.com with esmtp (Exim 2.05 #1 (Debian)) id 10xAF2-0000vR-00; Thu, 24 Jun 1999 14:12:36 +0000 Message-ID: <37721FD7.9947A3A1@sferacarta.com> Date: Thu, 24 Jun 1999 14:08:56 +0200 From: =?iso-8859-1?Q?Jos=E9?= Soares X-Mailer: Mozilla 4.5 [it] (Win95; I) X-Accept-Language: it MIME-Version: 1.0 To: Tiberiu Craciun CC: pgsql-sql@hub.org Subject: Re: [SQL] problem with PL/pgSQL References: <010101bebe2b$62327e20$0201a8c0@tibi.akela.ro> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Your function have some bugs; 1) The parser doesn't understand keywords like ENDIF but END IF (two words) 2) You must to use keyword INTO with the select command try this one instead: create function addtrafic (text, int8, int2) returns int2 as ' declare boo text; statia alias for $1 ; traficul alias for $2 ; directia alias for $3 ; begin select statie from trafic into boo where statie= $1; if not found then insert into trafic (statie) values( $1 ); end if; if $3 < 1 then update trafic set traf_in=traf_in+ $2 where statie= $1; else update trafic set traf_out=traf_out+ $2 where statie= $1; end if; return $3 ; end; ' language 'plpgsql'; Tiberiu Craciun ha scritto: > Part 1.1 Type: Plain Text (text/plain) > Encoding: quoted-printable -- ______________________________________________________________ PostgreSQL 6.5.0 on i586-pc-linux-gnu, compiled by gcc 2.7.2.3 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Jose'