Reputation: 861
If I have a sql query is it possible for me to add a cast to a dynamic parameter? Here is my sql query:
"SELECT DISTINCT MATERIAL.MATERIALID FROM DATA WHERE MATERIAL.MATERIALID = :VALUE "
I need to cast :VALUE
as a double and was just wondering if it's possible
Upvotes: 0
Views: 83
Reputation: 1270773
You can do this in SQL:
SELECT DISTINCT MATERIAL.MATERIALID
FROM DATA
WHERE MATERIAL.MATERIALID = cast(:VALUE as float)
However, it is a really, really, really bad idea to do equality comparisons on floating point representations of numbers. Two numbers might look the same, but compare differently. Are you sure you can't do the comparison as an integer?
Upvotes: 1