From: Tom Lane <tgl@sss.pgh.pa.us>
To: carlino@ilrspa.com
Cc: pgsql-sql@postgresql.org
Subject: Re: Problem with function & trigger
Date: Sat, 07 Jul 2001 15:28:06 -0400
Message-ID: <29529.994534086@sss.pgh.pa.us> (raw)
In-Reply-To: <3B46ED17.9F3EACA4@ilrspa.com>
References: <3B46ED17.9F3EACA4@ilrspa.com>
Carlo Vitolo <carlino@ilrspa.com> writes:
> This does not work. The error is ERROR: pg_atoi: error in "12.00": can't
> parse ".00"
What PG version are you running? It seems to work fine for me in
current sources:
regression=# create table magazzino (quantita numeric(10,2),
regression(# descrizione text);
CREATE
regression=# create table scarico (quantita numeric(10,2),
regression(# descrizione text);
CREATE
regression=# insert into magazzino values(100, 'test1');
INSERT 400688 1
regression=# insert into magazzino values(200, 'test2');
INSERT 400689 1
<< create functions and triggers copied from your mail >>
regression=# insert into scarico values(10.4, 'test1');
INSERT 400694 1
regression=# select * from magazzino ;
quantita | descrizione
----------+-------------
200.00 | test2
89.60 | test1
(2 rows)
regression=# delete from scarico;
DELETE 1
regression=# select * from magazzino ;
quantita | descrizione
----------+-------------
200.00 | test2
100.00 | test1
(2 rows)
BTW, the way you are writing the functions seems bizarrely inefficient.
Why not just:
CREATE FUNCTION "togliscar" () RETURNS opaque AS 'BEGIN
UPDATE magazzino
SET quantita = quantita - NEW.quantita
WHERE descrizione = NEW.descrizione;
RETURN NEW;
END;
' LANGUAGE 'plpgsql';
regards, tom lane
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, carlino@ilrspa.com
Subject: Re: Problem with function & trigger
In-Reply-To: <29529.994534086@sss.pgh.pa.us>
* 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