Received: from shiva.jussieu.fr (shiva.jussieu.fr [134.157.0.129]) by hub.org (8.9.3/8.9.3) with ESMTP id HAA04675 for ; Thu, 24 Jun 1999 07:53:10 -0400 (EDT) (envelope-from basier@ipgp.jussieu.fr) Received: from toutatis.ipgp.jussieu.fr (root@toutatis.ipgp.jussieu.fr [134.157.26.27]) by shiva.jussieu.fr (8.9.3/jtpda-5.3.1) with ESMTP id NAA05123 ; Thu, 24 Jun 1999 13:52:01 +0200 (CEST) Received: from sismo1.ipgp.jussieu.fr (sismo1.ipgp.jussieu.fr [134.157.27.131]) by toutatis.ipgp.jussieu.fr (8.9.2/jtpda-5.3.1) with ESMTP id NAA18903 ; Thu, 24 Jun 1999 13:49:03 +0200 (MET DST) Received: from ipgp.jussieu.fr (geosp5 [134.157.27.5]) by sismo1.ipgp.jussieu.fr (8.8.8/jtpda-5.2) with ESMTP id NAA22828 ; Thu, 24 Jun 1999 13:53:16 +0200 (MET DST) Sender: basier@ipgp.jussieu.fr Message-ID: <37721BDE.9EF8D903@ipgp.jussieu.fr> Date: Thu, 24 Jun 1999 13:51:59 +0200 From: Eric BASIER X-Mailer: Mozilla 4.02 [en] (X11; I; SunOS 5.6 sun4m) 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 I insert my response in your text Tiberiu Craciun wrote: > I have a table and a function defined like that : create table trafic > ( > statie text, > traf_in int8 default 0, > traf_out int8 default 0 > ); create function addtrafic (text, int8, int2) returns int2 as ' > declare > statia alias for $1 ; > traficul alias for $2 ; > directia alias for $3 ; > begin > select * from trafic where statie= $1; > if not found then > insert into trafic (statie) values( $1 ); there is an error here ^ the good sentence is : insert into trafic (statie) values ($1) ; > endif; > 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; > endif; > return $3 ; > end; > ' language 'plpgsql'; when I run this SQL : select > addtrafic('station1',10,0) as test; I got an error like that : NOTICE: > plpgsql: ERROR during compile of addtrafic near line 20ERROR: parse > error at or near ";" and i don't know what is wrong, can someone help > me ? -- Basier Eric e-mail : basier@ipgp.jussieu.fr http://geoscope.ipgp.jussieu.fr IPGP Observatoires Sismologie-Volcanologie 4,Place Jussieu 75005 Paris Tour 24-14 4eme Etage Tel 01 44 27 38 96