Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 11 total
Thread Engine.FloatToAnsiStr
Fri, Jan 20 2006 8:58 AMPermanent Link

FloatToAnsiStr has a little problem. Or something does anyway. If I format
a double containing the number 87810671861 with it, the SQL generated
causes an error in IntToStr during ExecSQL. The value is going into a
float field FWIW. I suspect this is because there is no decimal point
output by the function, which is the same as the normal FloatToStr - I
tried the DBISAM one since I thought this might be an instant cure.
Indeed, a quick bit of code to append a decimal if there isn't one sorts
it out.

Can I suggest that FloatToAnsiStr be updated to do the decimal check?

My code is as simple as:
 szTemp := Engine.FloatToAnsiStr(avValues[nLoop]);
 if Pos('.', szTemp) = 0 then
   szTemp := szTemp + '.';                     
 xSQL.Add(szTemp + ',');


/Matthew Jones/
Fri, Jan 20 2006 9:50 AMPermanent Link

"Ralf Mimoun"
Matthew Jones wrote:
....
> Can I suggest that FloatToAnsiStr be updated to do the decimal check?
>
> My code is as simple as:
>  szTemp := Engine.FloatToAnsiStr(avValues[nLoop]);
>  if Pos('.', szTemp) = 0 then
>    szTemp := szTemp + '.';

Maybe even "+ '.0'", just to be sure

Ralf

Fri, Jan 20 2006 11:02 AMPermanent Link

Good point, but it has worked so far as it. Can't hurt though can it.

/Matthew Jones/
Fri, Jan 20 2006 4:23 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< FloatToAnsiStr has a little problem. Or something does anyway. If I
format a double containing the number 87810671861 with it, the SQL generated
causes an error in IntToStr during ExecSQL. The value is going into a float
field FWIW. >>

Is this in the IDE only ?  If so, then you can safely ignore the error.
DBISAM should handle putting an integer into a float field with no problem.

--
Tim Young
Elevate Software
www.elevatesoft.com

Mon, Jan 23 2006 5:45 AMPermanent Link

No, this is at runtime. The number is too big to be an INT, so DBISAM is
falling over on it. I'd post some SQL, but my code is too broken at the
moment. Just try something like

INSERT into ANYTABLE
(MyFloatField) VALUES (87810671861)

You'll get an integer overflow that you don't if there is a decimal point
at the end of the number.

/Matthew Jones/
Mon, Jan 23 2006 5:16 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matt,

<< No, this is at runtime. The number is too big to be an INT, so DBISAM is
falling over on it. I'd post some SQL, but my code is too broken at the
moment. Just try something like  >>

I just tried the following with the DBDEMOS Orders table and it worked fine:

INSERT into orders (CustNo,EmpNo,ItemsTotal) VALUES (1000,10,87810671861)

Are you recompiling using the DBISAM source code ?

--
Tim Young
Elevate Software
www.elevatesoft.com

Tue, Jan 24 2006 5:40 AMPermanent Link

> Are you recompiling using the DBISAM source code ?

Not that I'm aware of! 8-) I have a path "E:\Comp\dbisam4\d7\code" in my
environment, which I think is added automatically.

I'll post the SQL I'm using in a while once another bug that cropped up in
another project gets fixed. Okay, I've posted it below (with the '.' in
the data to correct it).

/Matthew Jones/

DROP TABLE InputData;
CREATE TABLE InputData (
"idUnitID" INTEGER NOT NULL,
"idUnitName" VARCHAR(32),
"idActive" BOOLEAN,
"idVALUE_1" FLOAT,
"idVALUE_2" FLOAT,
"idVALUE_3" FLOAT,
"idVALUE_4" FLOAT,
"idVALUE_5" FLOAT,
"idVALUE_6" FLOAT,
"idVALUE_7" FLOAT,
"idVALUE_8" FLOAT,
"idVALUE_9" FLOAT,
"idVALUE_10" FLOAT,
"idVALUE_11" FLOAT,
"idVALUE_12" FLOAT,
"idVALUE_13" FLOAT,
"idVALUE_14" FLOAT,
"idVALUE_15" FLOAT,
"idVALUE_16" FLOAT,
"idVALUE_17" FLOAT,
"idVALUE_18" FLOAT,
"idVALUE_19" FLOAT,
"idVALUE_20" FLOAT,
"idVALUE_21" FLOAT,
"idVALUE_22" FLOAT,
"idVALUE_23" FLOAT,
"idVALUE_24" FLOAT,
"idVALUE_25" FLOAT,
"idVALUE_26" FLOAT,
"idVALUE_27" FLOAT,
PRIMARY KEY ("idUnitID") COMPRESS NONE
LOCALE CODE 0
USER MAJOR VERSION 1
);
CREATE NOCASE INDEX IF NOT EXISTS "IDX_idUnitName" ON "InputData"
("idUnitName");


INSERT INTO InputData
(
idUnitID,
idUnitName,
idActive,
idVALUE_1,
idVALUE_2,
idVALUE_3,
idVALUE_4,
idVALUE_5,
idVALUE_6,
idVALUE_7,
idVALUE_8,
idVALUE_9,
idVALUE_10,
idVALUE_11,
idVALUE_12,
idVALUE_13,
idVALUE_14,
idVALUE_15,
idVALUE_16,
idVALUE_17,
idVALUE_18,
idVALUE_19,
idVALUE_20,
idVALUE_21,
idVALUE_22,
idVALUE_23,
idVALUE_24,
idVALUE_25,
idVALUE_26,
idVALUE_27
)
VALUES (
56,
'Chazy Central Rural - HS - Chazy',
True,
87810671861.,
8944.,
0.671,
22.54,
96.92,
94.,
94.,
88.,
94.,
87810671861.,
8944.,
0.671,
22.54,
96.92,
94.,
94.,
88.,
94.,
87810671861.,
8944.,
0.671,
22.54,
96.92,
94.,
94.,
88.,
94.
)
Tue, Jan 24 2006 7:19 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< Not that I'm aware of! 8-) I have a path "E:\Comp\dbisam4\d7\code" in my
environment, which I think is added automatically. >>

Okay, that should be only DCUs.

<< I'll post the SQL I'm using in a while once another bug that cropped up
in another project gets fixed. Okay, I've posted it below (with the '.' in
the data to correct it). >>

I ran it here without the '.' and it works fine (4.22 B4 DBSYS).

--
Tim Young
Elevate Software
www.elevatesoft.com



Wed, Jan 25 2006 5:31 AMPermanent Link

Okay, I'll see if I can experiment further, and see where the exception is
coming from.

/Matthew Jones/
Thu, Feb 2 2006 12:04 PMPermanent Link

Okay, I had this again with a largeint. So I added the source directory
and can see what is happening. This is only an issue in the IDE, as I then
see the exception. ParseExpression8 is calling IsAnInteger, which is
failing of course but that's fine as it is trapped by your code. It then
goes to try a longint or a float.

It would be nice to use the TryStrToInt instead, but this is essentially
only a concern at debug time.

/Matthew Jones/
Page 1 of 2Next Page »
Jump to Page:  1 2
Image