Inserting floats into a Navision database table from Delphi 3.0

Hello, I have a problem, I’m trying to insert data into a table, i can insert data as long as it is text, or integer values, as soon as i try to insert a decimal value like 5.43 i get a nasty access violation when i try to run my query from Delphi. Can anyone please tell me what i’m doing wrong? I’m using Codbc and I have all my ODBC settings set correctly.

Just to make sure I understand your problem: You are using a Query within Delphi to write data via ODBC into a Navision table? Which data type do you use in Delphi for the Decimal: Real, Decimal, Single or Extended? Is it possible that you have a range-overflow? Try to use the {$REALCOMPATIBILITY ON} compiler directive to turn Real back into the six-byte type. Another problem might be the Decimal separator: Is the Dot (like in 5.43) used in both applications or might it be that the country settings are set to comma (5,43)? What if you send a value like “5” wihout any fractions? You also might want to mention, which NF version you are using, and which Delphi version. An example of the SQL-Statment you send from Delphi could also be helpful to track down the problem. Marcus Marcus Fabian phone: +41 79 4397872 m.fabian@thenet.ch

Thanks for the help, I use Delphi 3.0 i pass values (at this point i hardcode them in) such as this: 3.14 I do not use the , to separate the decimals. my query looks like this: INSERT INTO Shipment(“SHIP_NUM”,“SHIP_WGT”) VALUES(9339,3.14) I tried sending just a 3 but it did not help. i tried formatting the values to 0003.14 or 3.14000 no result. I even go to Delphi DBExplorer and run the query there, i get the same results, only worse, DBExplorer bombs, and exits. I use Navsion Financials software version: CA 2.60.B (CA 2.60.B) Regards,

Hi I had the same problem when I tried to do the same thing in C++ using Cfront. I could not enter decimal values in fields even though the data seemed ok. The thing is, that data must first be formatted to Navision decimal format. I haven’t done any programming in Delphi, but surely there must be some functions that convert data available. Read the manual under conversion again and maybe you’ll get some answers there. hope it helps Andrej Renko andrej.renko@adacta.si

Thanks, I do not have any manuals handy, This is my 3rd day working with Navision, I’m doing a project that takes Btrieve data, and dumps it into a Navision table. I have never created a Navision table, or assigned field types to the fields… BTW, How did you format it in CFront?

Do jou have to transfer data between BTrieve and NF on a life basis or only once or once every x days? If you don’t need a live connection the easises way might be to export the BTrieve data in a comma separated simple ASCII file and use a Navision Dataport to suck it in. Marcus Marcus Fabian phone: +41 79 4397872 m.fabian@thenet.ch

I have to dump live data in realtime to the Navision table from Btrieve, i’m still fighting with it… =(

there is a function in CFRONT DBL_Str_2_BCD(paramateres here). That’s it. That is why I told you that there should be something similar in Delphi. I am not familiar with Delphi, so I cannot help you in that matter. Andrej Renko

If BCD (= Binary coded decimal) is working, I would propose to use a different data type for the delphi “decimal”: COMP should work as it’s the native Intel processor real You might also try TBCDType. Marcus Marcus Fabian phone: +41 79 4397872 m.fabian@thenet.ch