Quantcast
Channel: Microsoft Dynamics AX Forum - Recent Threads
Viewing all articles
Browse latest Browse all 73760

AX send bad request to SQL Server

$
0
0

Hello,

I work with Dynamics AX2009 and I'm face to a problem that I can't understand. It seems that AX have a problem to correctly generate SQL query when we do some calculations in the WHERE.

I want to execute this X++ query :

WHILE SELECT salesId, LineNum, salesQty, SalesPrice, linePercent, LineAmount
FROM SalesLine
WHERE SalesLine.salesId >= 'K0100000'
&& salesLine.LineAmount > (salesLine.SalesPrice*salesLine.salesQty*(1 - salesLine.linePercent/100) + 0.01)
{
}

But if I create a trace in SQL Server Profiler for survey what is send to it, I can see this :

declare @p1 int
set @p1=1076836550
declare @p2 int
set @p2=195416459
declare @p5 int
set @p5=16
declare @p6 int
set @p6=1
declare @p7 int
set @p7=2
exec sp_cursorprepexec @p1 output,@p2 output,N'@P1 nvarchar(5),@P2 nvarchar(21),@P3 bigint,@P4 numeric(28, 12),@P5 bigint',N'SELECT A.SALESID,A.LINENUM,A.SALESQTY,A.ITEMID,A.LINEAMOUNT,A.SALESPRICE,A.LINEPERCENT,A.RECID FROM SALESLINE A WHERE ((DATAAREAID=@P1) AND ((SALESID>=@P2) AND (LINEAMOUNT>(((SALESPRICE*SALESQTY)*(@P3-(LINEPERCENT/@P4)))+@P5))))',@p5 output,@p6 output,@p7 output,N'kl',N'K0100000',100,1.000000000000,254
select @p1, @p2, @p5, @p6, @p7

if I rebuild the query it give :

SELECTA.SALESID,A.LINENUM,A.SALESQTY,A.ITEMID,A.LINEAMOUNT,A.SALESPRICE,A.LINEPERCENT,A.RECID
FROMSALESLINE A
WHEREDATAAREAID = N'kl'
  ANDSALESID>=N'K0100000'
  ANDLINEAMOUNT> (SALESPRICE*SALESQTY*(100-LINEPERCENT/1.00)) + 254

Which is not the same at all ! We can see that the 1 and the 100 have been exchange (i did some tests, it seems really to be an exchange) and the 0.01 and been change into 254 ?!

Does someone ever seen something like that ? And how can I be sure that ALL of the other queries send are OK ?


Thanks.

Ps : Sorry for mistakes, I'm French


Viewing all articles
Browse latest Browse all 73760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>