pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: José Soares <jose@sferacarta.com>
To: Tiberiu Craciun <tiberiu@akela.ro>
Cc: pgsql-sql@hub.org
Subject: Re: [SQL] problem with PL/pgSQL
Date: Thu, 24 Jun 1999 14:08:56 +0200
Message-ID: <37721FD7.9947A3A1@sferacarta.com> (raw)
References: <010101bebe2b$62327e20$0201a8c0@tibi.akela.ro>

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'





view thread (11+ messages)  latest in thread

Message-ID: <37721FD7.9947A3A1@sferacarta.com>
Permalink:  ../37721FD7.9947A3A1@sferacarta.com/
Also on:    postgresql.org/message-id/37721FD7.9947A3A1@sferacarta.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: jose@sferacarta.com, tiberiu@akela.ro, pgsql-sql@hub.org
  Subject: Re: [SQL] problem with PL/pgSQL
  In-Reply-To: <37721FD7.9947A3A1@sferacarta.com>
  References: <010101bebe2b$62327e20$0201a8c0@tibi.akela.ro> <37721FD7.9947A3A1@sferacarta.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox