Simplicty and flexibility!


Wrong Amount coming from a text field


Started by Marco Marchesi
Search
You will need to Sign In to be able to add or comment on the forum!

Wrong Amount coming from a text field

Hi DataEase, we have problem when I put a text files of 254 char in a "number field" . The number field doesn't report the correct amount .

In fact I have in the value field of the table 123456789 (length 9) but the result in the amount field 12345679 (length 8).

I have the same wrong result if I use another table as output.

WHY?  (dataease 8.2.0.1700 version)

Here the DQL :

define "Amount" number .

define "numstring" numeric string 14 .

for BogmAllModules with Policy_Id = 003873 and Variable_Code = "AGAMOUN1" ;

assign numstring := Value .

assign Amount := Value .

list records

Policy_Id ;

Module_Code ;

Variable_Code ;

Value ;

Amount ;

numstring ;

length(Value) ;

length(Amount) ;

length(numstring) .

end .

Here the results :

Here the Table


Written by Marco Marchesi 12/12/17 at 09:40:20 Dataease [{8}]FIVE

Re:Wrong Amount coming from a text field

Hi Marco

You might be able to use a work around like the following (Which works):-

define "pobn" number .
define "pobns" numeric string 14 .
define "tekts" text 10 .

tekts := "123456789" .

pobn := tekts/100 .
pobns := tekts .

list records
pobn*100 ;
pobns .


Written by Peter Birney, PB Associates 13/12/17 at 08:52:12 Dataease [{8}]FIVE

Re:Wrong Amount coming from a text field

Just checked and this is an old bug. It is definitely there in 6.x too.

The problem is that DataEase convert it to a 8 digit number and then round up the last 9.

so if you had used 555555555 you would have gotten 55555556,

This is because there are no decimal points in computers. They are just introduced for human interface So for a computer that use round this is "logical".

So it is a bug in the text to number conversion that limit the size of the number to 8 digits.

So the solution is just to force the number conversion to happen before the text being converted to the number temp.

NumberStr := TextStr + 0 .

TestDQL:
define "NumberStr" number .

define "NumStr" numeric string 14 .

define "TextStr" text .

TextStr := "12345678901234" .

NumberStr := TextStr + 0 .

NumStr := TextStr .

list records

NumberStr ;

NumStr ;

TextStr .


Now the temp will be allocated to a number and not a string and it all works.

Know DataEase workaround to force number conversion.


Written by DataEase 13/12/17 at 10:35:40 Dataease [{8}]FIVE
DG3_ForumList