Received: from ns.canad.ro (IDENT:root@ns.canad.ro [193.230.177.1]) by hub.org (8.9.3/8.9.3) with ESMTP id GAA65594 for ; Thu, 24 Jun 1999 06:25:03 -0400 (EDT) (envelope-from tiberiu@akela.ro) Received: from ns (root@ns.akela.ro [193.226.47.105]) by ns.canad.ro (8.9.3/8.9.3) with ESMTP id NAA05818 for ; Thu, 24 Jun 1999 13:23:50 +0300 Received: from tibi (tibi.akela.ro [192.168.1.2]) by ns (8.9.1/8.9.1) with SMTP id NAA18474 for ; Thu, 24 Jun 1999 13:24:10 -0200 Message-ID: <010101bebe2b$62327e20$0201a8c0@tibi.akela.ro> From: "Tiberiu Craciun" To: Subject: problem with PL/pgSQL Date: Thu, 24 Jun 1999 13:21:54 +0300 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00FE_01BEBE44.87135FC0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 4.72.3110.5 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 This is a multi-part message in MIME format. ------=_NextPart_000_00FE_01BEBE44.87135FC0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I have a table and a function defined like that : create table trafic (=20 statie text,=20 traf_in int8 default 0, traf_out int8 default 0 ); create function addtrafic (text, int8, int2) returns int2 as ' declare=20 statia alias for $1 ; traficul alias for $2 ; directia alias for $3 ; begin select * from trafic where statie=3D $1; if not found then insert into trafic (statie) values( $1 ); endif; if $3 < 1 then update trafic set traf_in=3Dtraf_in+ $2 where statie=3D = $1; else update trafic set traf_out=3Dtraf_out+ $2 where = statie=3D $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 20 ERROR: parse error at or near ";" and i don't know what is wrong, can someone help me ? ------=_NextPart_000_00FE_01BEBE44.87135FC0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I have a table and a function defined like that = :
 
create table trafic (
    statie = text,=20
    traf_in int8 default 0,
    = traf_out=20 int8 default 0
);
 
create function addtrafic (text, int8, int2) returns = int2 as=20 '
    declare=20
         statia alias for $1 = ;
         traficul alias for = $2=20 ;
         directia alias for = $3=20 ;
   =20 begin
         select * from = trafic=20 where statie=3D $1;
         = if not=20 found=20 then
           = ;     =20 insert into trafic (statie) values( $1=20 );
        =20 endif;
         if $3 < 1=20 then
           = ;     =20 update trafic set traf_in=3Dtraf_in+ $2 where statie=3D=20 $1;
        =20 else
           = ;     =20 update trafic set traf_out=3Dtraf_out+ $2 where statie=3D=20 $1;
        =20 endif;
         return $3=20 ;
    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=20 addtrafic near line 20
ERROR: parse error at or near=20 ";"
 
and i don't know what is wrong, can = someone help=20 me ?
------=_NextPart_000_00FE_01BEBE44.87135FC0--