Subject Re: [ib-support] Please Help - Calculate fields(urgent)
Author Paul Reeves
news.clix.pt wrote:
> Thanks for the anwser
> i'm using dialect 3
>
>
> my table is
> CREATE TABLE COMPRAS (
> ID INTEGER NOT NULL,
> REF VARCHAR(15),
> CODEM VARCHAR(5) NOT NULL,
> QTD INTEGER NOT NULL,
> DATA DATE,
> QTDVEN NUMERIC(18,4) NOT NULL,
> CAMBIO NUMERIC(18,8) NOT NULL,
> PRECOTOTAL NUMERIC(18,4),
> INDISPONIVEIS SMALLINT NOT NULL,
> CODMOE VARCHAR(3) NOT NULL,
> PREUNIMOE COMPUTED BY ((PRECOTOTAL/QTD)),
> PREUNIEUR COMPUTED BY ((PRECOTOTAL*CAMBIO/QTD ));
>
>
> PRECOTOTAL=157809.0000
> CAMBIO=1.00000000
> QTD=1077
>
> PREUNIMOE is OK
> PREUNIEUR is not
>
>
> Any comment?
>

OK, here is what I have tried with ISQL:

====

show sql dialect;

create table test_comp(
PRECOTOTAL NUMERIC(18,4),
CAMBIO NUMERIC(18,8) NOT NULL,
QTD INTEGER NOT NULL,
PREUNIMOE COMPUTED BY ((PRECOTOTAL/QTD)),
PREUNIEUR COMPUTED BY ((PRECOTOTAL*CAMBIO/QTD ))
);

insert into test_comp (PRECOTOTAL, CAMBIO, QTD)
values (157809.0000, 1.00000000, 1077 );


select * from test_comp;

====

yeilds this result:


PRECOTOTAL CAMBIO QTD PREUNIMOE PREUNIEUR
=========== =========== ======== =============== =================

157809.0000 1.00000000 1077 146.5264 146.526462395543


Fundamentally, I'm happy with this result, so I suspect that your error
is outside the engine. What software are you using with Firebird?


Paul
--

Paul Reeves
http://www.ibphoenix.com
Supporting users of Firebird and InterBase