Subject | Re: [firebird-support] computed by columns |
---|---|
Author | Ivan Prenosil |
Post date | 2004-06-03T11:25:50Z |
I can't reproduce what you describe.
Here is screenshot of test script:
CREATE DATABASE 'c:\test.fdb' USER 'SYSDBA' PASSWORD 'masterkey';
CREATE TABLE T (
A NUMERIC(8,2),
B NUMERIC(8,2),
X COMPUTED BY (A*B),
Y NUMERIC(8,2) COMPUTED BY (A*B)
);
INSERT INTO T(A,B) VALUES (12.34, 100.01);
INSERT INTO T(A,B) VALUES (56.78, 100.01);
SELECT * FROM T;
A B X Y
============ ============ ===================== ============
12.34 100.01 1234.1234 1234.12
56.78 100.01 5678.5678 5678.57
DROP DATABASE;
Here is screenshot of test script:
CREATE DATABASE 'c:\test.fdb' USER 'SYSDBA' PASSWORD 'masterkey';
CREATE TABLE T (
A NUMERIC(8,2),
B NUMERIC(8,2),
X COMPUTED BY (A*B),
Y NUMERIC(8,2) COMPUTED BY (A*B)
);
INSERT INTO T(A,B) VALUES (12.34, 100.01);
INSERT INTO T(A,B) VALUES (56.78, 100.01);
SELECT * FROM T;
A B X Y
============ ============ ===================== ============
12.34 100.01 1234.1234 1234.12
56.78 100.01 5678.5678 5678.57
DROP DATABASE;
----- Original Message -----
From: "James" <james_027@...>
To: <firebird-support@yahoogroups.com>
Sent: Thursday, June 03, 2004 3:10 AM
Subject: Re: [firebird-support] computed by columns
> Hi Ivan
>
> Ivan Prenosil wrote:
>
> > What are definitions of your domains ? I guess
> > D_MONEY and D_DISCOUNT_PERCENT are Numeric(x,2) ?
> >
> > In release notes for IB6 you can find some rules about arithmetic
> > operations:
> > "... If both operands are exact numeric, then multiplying or dividing
> > the operands produces
> > an exact numeric with a precision of 18 and a scale equal to the sum
> > of the scales of the
> > operands. ..."
> >
> > i.e. multiplying of four Numeric(x,2) values will produce
> > Numeric(18,8) result.
> >
> >
> > Also, what do you mean by "At first its data type was set at
> > numeric(15,2),
> > but after compiling it became numeric(18,8)" ? Did you use this syntax :
> > CREATE TABLE INVOICE ( ...
> > GRAND_TOTAL NUMERIC(15,2) COMPUTED BY ( ...
> > ?
> >
> >
> > Ivan
> >
> Since the Firebird behaves that way, are there some work around or do we
> just leave it as is? What if I really want it to be numeric(15,20)?
> Yes I use the syntax
>
> CREATE TABLE INVOICE ( ...
> GRAND_TOTAL NUMERIC(15,2) COMPUTED BY ( ...
>
> but after compiling it the grand_total numeric(15,2) became
> grand_total(18,8). You're right that both D_money and
> d_discount_percent are numeric(x,2)
>
>
> james