Subject | Re: [firebird-support] computed by columns |
---|---|
Author | Ivan Prenosil |
Post date | 2004-06-02T11:53:36Z |
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
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
----- Original Message -----
From: "James" <james_027@...>
To: <firebird-support@yahoogroups.com>
Sent: Tuesday, June 01, 2004 9:25 AM
Subject: [firebird-support] computed by columns
> hi guys,
>
> I have try to use the computed by when creating a table and here is what
> I discovered. For example if I had a table like this ...
>
> CREATE TABLE INVOICE (
> ID D_ID NOT NULL,
> INVOICE_NO D_ID,
> CUSTOMER_ID D_ID,
> INVOICE_DATE D_TRANSACTION_DATE,
> TOTAL_AMOUNT D_MONEY,
> DISCOUNT_1 D_DISCOUNT_PERCENT,
> DISCOUNT_2 D_DISCOUNT_PERCENT,
> DISCOUNT_3 D_DISCOUNT_PERCENT,
> LESS D_MONEY,
> ADJUSTMENT D_MONEY,
> GRAND_TOTAL COMPUTED BY (total_amount * (1-(discount_1/100)) *
> (1-(discount_2/100)) * (1-(discount_3/100)) - less - adjustment),
> SALES_AGENT D_ID,
> LOCATION VARCHAR(15) NOT NULL,
> REMARKS VARCHAR(240),
> STATUS CHAR(3) DEFAULT 'ACT' NOT NULL,
> CREATE_BY D_CREATE_BY,
> CREATE_ON D_CREATE_ON,
> EDIT_BY D_EDIT_BY,
> EDIT_ON D_EDIT_ON
> );
>
>
> As you can see the grand_total field has computed by properties. At
> first its data type was set at numeric(15,2), but after compiling it
> became numeric(18,8) and I think it was cause by the computed by
> properties. My question is this normal? or Is this what computed by for
> or does it has other uses?
>
> Please guide. Thanks
>
>
> regards,
> james