Re: [SQL] problem with PL/pgSQL

From: José Soares <jose(at)sferacarta(dot)com>
To: Tiberiu Craciun <tiberiu(at)akela(dot)ro>
Cc: pgsql-sql(at)hub(dot)org
Subject: Re: [SQL] problem with PL/pgSQL
Date: 1999-06-24 12:08:56
Message-ID: 37721FD7.9947A3A1@sferacarta.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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'

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Alexander Schneider 1999-06-24 12:12:23 Error on Update: ExecCheckPerms-bogus RT relid?
Previous Message Alexander Schneider 1999-06-24 12:08:12 Error on Update: ExecCheckPerms-bogus RT relid?