Numeric type in PL/pgSQL trigger: overflow problem - Mailing list pgsql-general

From Robert
Subject Numeric type in PL/pgSQL trigger: overflow problem
Date
Msg-id 38B02ABD.B2EEDAEB@robert.cz
Whole thread Raw
List pgsql-general
Hi,

 following function doesn't work with numeric type, when I change type
of 'total_no_vat' to anything else incl. float it works OK. What am I
doing wrong? Thanks for your help.

- Robert

CREATE TABLE deb_invoice_line_table (
        qty        NUMERIC(13,2),
        unit_price    NUMERIC(13,2),
        total_no_vat    NUMERIC(13,2),
        -- ...
)

CREATE FUNCTION deb_invoice_line_complete() RETURNS OPAQUE AS 'BEGIN
    NEW.total_no_vat := 5.2;
    RETURN NEW;
END;' LANGUAGE 'plpgsql';

CREATE TRIGGER deb_invoice_line_trigger
    BEFORE INSERT OR UPDATE
    ON deb_invoice_line_table
    FOR EACH ROW EXECUTE PROCEDURE deb_invoice_line_complete();

INSERT INTO deb_invoice_line_table (qty,unit_price) VALUES (3,33);

ERROR:  overflow on numeric ABS(value) >= 10^0 for field with precision
0 scale 2

pgsql-general by date:

Previous
From: Ed Loehr
Date:
Subject: Re: [GENERAL] Backend terminated abnormally error ?
Next
From: "Bruce Staples (ENZ)"
Date:
Subject: unsubscribe