Delphi: Delphi and Microsoft SQL Server 2005 bad calculations from function values

会有一股神秘感。 提交于 2019-12-11 08:58:25

问题


When i send this query on SQL Server 2005 with the Microsoft SQL Server Management Studio

SELECT dbo.MOV('Hi',10,2) + dbo.MOV('Hi2',8,2)

The query returns 400

The result of anything send to the function will return 200 except if the last two parameter where 0 the value of return will be 100 and the value type of return from the function its Decimal(12,2)

the problem, comes when I do the query on Delphi

Query.SQL.Add('SELECT dbo.MOV(''Hi'',10,2) + dbo.MOV(''Hi2'',8,2)');
Query.Open;
Query.Next;
ShowMessage(Query.Fields[0].AsString);

The Query returns 200 (on the message dialog), like if SQL Server is just taking the first Function and ignoring the second one, so what i could do get from SQL Server 2005 the right calculation in Delphi. Thanks.


回答1:


Try to clear Query.SQL before Query.SQL.Add.

Query.SQL.Clear
Query.SQL.Add('SELECT dbo.MOV(''Hi'',10,2) + dbo.MOV(''Hi2'',8,2)');

If you already have a query stored in SQL you will only see the result from the first one.



来源:https://stackoverflow.com/questions/5216227/delphi-delphi-and-microsoft-sql-server-2005-bad-calculations-from-function-valu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!