Getting Decimals from SQL Query

sfo
Member Posts: 12
Hello,
I've been searching the forums for some time but I haven't been able to find a solution to my problem. Though it's pretty standard stuff. O:)
I'm making SQL Queries in my (SQL 2000) DB and getting sums from the DB.
I can't assign the returned values neither to an Integer neither to a Decimal as they are of Variant type:
All I can do is pass them to another automation:
I've been trying everything I could to use the values in C/AL... Would someone have run into the same problem?
Stephan
I've been searching the forums for some time but I haven't been able to find a solution to my problem. Though it's pretty standard stuff. O:)
I'm making SQL Queries in my (SQL 2000) DB and getting sums from the DB.
select sum(Quantity) as SMQ, sum(Amount) as SMA from ['+CompName+'$Sales Invoice Line] ...
I can't assign the returned values neither to an Integer neither to a Decimal as they are of Variant type:
TempA := rsRequest0.Fields.Item('SMA').Value; // Does not work
All I can do is pass them to another automation:
xlSheet.RANGE('G'+FORMAT(iCurROw)).VALUE := rsRequest0.Fields.Item('SMA').Value;
I've been trying everything I could to use the values in C/AL... Would someone have run into the same problem?
Stephan
0
Comments
-
1) Which NAV version?
2) Did you tried to assign the field into variable of type "'Microsoft ActiveX Data Objects 2.7 Library'.Field" first and than assign the .Value of this variable to the target variable?0 -
kine wrote:1) Which NAV version?
2) Did you tried to assign the field into variable of type "'Microsoft ActiveX Data Objects 2.7 Library'.Field" first and than assign the .Value of this variable to the target variable?
Hello Kamil,
Thanks for your quick reply.
I have 3.7. I have created variables from the type you give and I can assign the variant to them. But when I assign the .Value of this .Field variable to a decimal, I have the same error message: This data type is not supported by C/SIDE. You can access data from any of the following type; VT_VOID, VT_I2, VT_I4, ...0 -
It can be possible that the result you got is NULL and than you cannot assign that. You need to be sure that result of your query has no NULL values or you need to test the value before you assign it into Decimal.0
-
kine wrote:It can be possible that the result you got is NULL and than you cannot assign that. You need to be sure that result of your query has no NULL values or you need to test the value before you assign it into Decimal.
Unfortunately it cannot be NULL because it's a select sum().0 -
-
Yes but there were no NULL entries.
But you put me on the way and I found a workaround: instead of 'SELECT SUM()' I do a 'SELECT STR(SUM())' and then EVALUATE the result. THat's a bit akward but it works.
Thanks.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