Converting SQL-Decimal to Navision-Decimal (NAV2017)

FragenFrager
Member Posts: 69
Hello,
currently I try to import the value of a decimal field from a SQL database into a Navision database. I usually do this via ado recordset and a variable of type Variant. For decimal fields this does not seem to go if I have understood correctly because of the fact that the SQL decimal field are float 9-bit, whereas in the case of Navision decimal fields it is 8-bit float. I have therefore tried to convert the decimal decimal fields before the import with cast, or convert into the appropriate format, without success. It seems as if Navision failed in the mere attempt to read the value of the SQL decimal fields somehow somewhere. Here is the corresponding code:
With the SQL statement I open the recordset and try to convert the field max_ Loading Weight into a decimal data field with 2 decimal places. Then I try to use EVALUATE to transfer the value of the (converted) field max_Loading Weight to the variable lvaVariant. Here the debugger shows that the EVALUATE fails; For the value of the variable lvaVariant, "Value" is displayed instead of the actual numeric value, if I interpreted it properly hides behind it an undefined value. Attempts to convert the decimal field into a field of type money or float also fail.
I have tried it with a stream (more specifically 'Microsoft ActiveX Data Objects 2.8 Library'.Stream and a field' Microsoft ActiveX Data Objects 2.8 Library'.Field 'adField):
What I've noticed is that when I look at the contents of the max_load weight field directly in the SQL Server Management Studio, 20 decimal places are displayed, the actual decimal places are displayed, the rest is filled with zeros. Is this possibly the problem, and how can it be solved? As I said before, any attempt to access the value of the field from the Navision page fails.
currently I try to import the value of a decimal field from a SQL database into a Navision database. I usually do this via ado recordset and a variable of type Variant. For decimal fields this does not seem to go if I have understood correctly because of the fact that the SQL decimal field are float 9-bit, whereas in the case of Navision decimal fields it is 8-bit float. I have therefore tried to convert the decimal decimal fields before the import with cast, or convert into the appropriate format, without success. It seems as if Navision failed in the mere attempt to read the value of the SQL decimal fields somehow somewhere. Here is the corresponding code:
GtxSQLStatementWeight: = STRSUBSTNO (gTxSELECT, '*' + ',' + convert (decimal (5,2), [max_ LoadingWeight]) ', gTxT_ExportOrderHead, gTxT_ExportOrderHead_Print, 1, gTxT_ExportOrderHeader_IsPrint, 0); gatADORecordSet3.Open (gtxSQLStatementWeight, gatADOConnection, ginOpenMethod, ginLockMethod); EVALUATE (lvaVariant, gatADORecordSet3.Fields.Item (FORMAT (gTxT_ExportOrderHead_maxWeight)) Value);
With the SQL statement I open the recordset and try to convert the field max_ Loading Weight into a decimal data field with 2 decimal places. Then I try to use EVALUATE to transfer the value of the (converted) field max_Loading Weight to the variable lvaVariant. Here the debugger shows that the EVALUATE fails; For the value of the variable lvaVariant, "Value" is displayed instead of the actual numeric value, if I interpreted it properly hides behind it an undefined value. Attempts to convert the decimal field into a field of type money or float also fail.
I have tried it with a stream (more specifically 'Microsoft ActiveX Data Objects 2.8 Library'.Stream and a field' Microsoft ActiveX Data Objects 2.8 Library'.Field 'adField):
GvdReadADOFieldDec (adField: Automation "'Microsoft ActiveX Data Objects 2.8 Library'.Field") DecimalValue: Decimal CREATE (Adstream, FALSE, TRUE); adStream.Open; adStream.WriteText (FORMAT (adField.Value)); AdStream.Position: = 0; IF EVALUATE (DecimalValue, adStream.ReadText) THEN;The WriteText method fails here.
What I've noticed is that when I look at the contents of the max_load weight field directly in the SQL Server Management Studio, 20 decimal places are displayed, the actual decimal places are displayed, the rest is filled with zeros. Is this possibly the problem, and how can it be solved? As I said before, any attempt to access the value of the field from the Navision page fails.
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions