Rounding issue with PG numeric columns and TCL triggers
Posted: Wed 24 Jun 2009 13:43
Hello,
We are having a weird rounding issue through UniDac when we've got a TCL trigger function attached to a PostgreSQL table with a field defined as numeric (with no precision). The following is the SQL I used to set up a test:
Using this through a small project in Delphi using a TUniTable and a grid, if I edit a record in this table and enter 1.45 into f1 and 1.45 into f2, f1 rounds to 1 and f2 saves 1.45 properly. If I disable the TCL trigger (but leave the plpgsql trigger enabled) the issue goes away. If I make these edits through PGAdmin with both triggers enabled, I don't have the rounding issue. Both fields properly save 1.45.
Following are the properties that I've changed from default for the TUniTable
I set up the DBMonitor and ran the SQLs that it logged straight through PGAdmin and they seemed to work fine.
We are using PostgreSQL 8.3.5, UniDac 2.7 and Delphi 7.
Any ideas what may be going on here?
Thanks
We are having a weird rounding issue through UniDac when we've got a TCL trigger function attached to a PostgreSQL table with a field defined as numeric (with no precision). The following is the SQL I used to set up a test:
Code: Select all
CREATE TABLE t1( id integer, f1 numeric, f2 numeric(22,4) );
CREATE OR REPLACE FUNCTION bogus_function()
RETURNS trigger AS
$BODY$BEGIN
return NEW;
END;
$BODY$
LANGUAGE 'plpgsql' STABLE STRICT
COST 100;
CREATE TRIGGER bogustrigger
BEFORE UPDATE OR DELETE
ON t1
FOR EACH ROW
EXECUTE PROCEDURE bogus_function();
CREATE OR REPLACE FUNCTION bogus_function2()
RETURNS trigger AS
$BODY$
return [array get NEW]
$BODY$
LANGUAGE 'pltcl' VOLATILE SECURITY DEFINER
COST 100;
CREATE TRIGGER bogustrigger2
BEFORE UPDATE OR DELETE
ON t1
FOR EACH ROW
EXECUTE PROCEDURE bogus_function2();
Following are the properties that I've changed from default for the TUniTable
Code: Select all
Options.DefaultValues := True;
Options.UpdateAllFields := False;
Options.StrictUpdate := False;
LockMode:= lmNone;
RefreshOptions:= [ roAfterUpdate ];
We are using PostgreSQL 8.3.5, UniDac 2.7 and Delphi 7.
Any ideas what may be going on here?
Thanks