pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Carlo Vitolo <carlino@ilrspa.com>
To: pgsql-sql@postgresql.org
Subject: Problem with function & trigger
Date: Sat, 07 Jul 2001 13:05:59 +0200
Message-ID: <3B46ED17.9F3EACA4@ilrspa.com> (raw)

This does not work. The error is ERROR: pg_atoi: error in "12.00": can't
parse ".00"

CREATE FUNCTION "togliscar" () RETURNS opaque AS 'BEGIN
UPDATE magazzino SET quantita = (SELECT quantita FROM magazzino WHERE
descrizione = NEW.descrizione )
- NEW.quantita WHERE descrizione = NEW.descrizione;
RETURN NEW;
END;
' LANGUAGE 'plpgsql';



CREATE TRIGGER "togliscarico" BEFORE INSERT ON "scarico"  FOR EACH ROW
EXECUTE PROCEDURE
"togliscar" ();

This works.


CREATE FUNCTION "delscar" () RETURNS opaque AS 'BEGIN
UPDATE magazzino SET quantita = (SELECT quantita FROM magazzino WHERE
descrizione = OLD.descrizione )
+ OLD.quantita WHERE descrizione = OLD.descrizione;
RETURN OLD;
END;
' LANGUAGE 'plpgsql';

CREATE TRIGGER "delscarico" BEFORE DELETE ON "scarico"  FOR EACH ROW
EXECUTE PROCEDURE
"delscar" ();

The field quantita is numeric(10,2).

Both functions works if quantita is integer.

Any hint?

Bye!




view thread (6+ messages)  latest in thread

Message-ID: <3B46ED17.9F3EACA4@ilrspa.com>
Permalink:  ../3B46ED17.9F3EACA4@ilrspa.com/
Also on:    postgresql.org/message-id/3B46ED17.9F3EACA4@ilrspa.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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: carlino@ilrspa.com
  Subject: Re: Problem with function & trigger
  In-Reply-To: <3B46ED17.9F3EACA4@ilrspa.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