I have a query I’m converting to a named query. One parameter is an INT4, another a string.
The string parameter can have one of three values: (‘site1’), (‘site2’) or (‘site1’,‘site2’).
In the named query I am attempting to use the string parameter as follows:
…WHERE a.site IN ‘{site}’
If I test with the value “(‘site1’)” – not sending in the double quotes – it returns this error:
GatewayException: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near ‘site1’.
I have tested any number of other permutations, but cannot find a way to make this work. I can format the string supplied as a parameter any way necessary, if anyone can advise. thanks
I gave up on fiddling with that and rewrote my query as follows:
SELECT 0 as ‘Select’
,itemId
,itemNumber
,description
,CASE WHEN (SELECT COUNT(*) FROM dbo.v_ivInventory i INNER JOIN dbo.fnT_SplitVarchar(:site,’,’,‘0’) a ON i.site = a.item
WHERE w.itemId = i.itemId
–and i.site IN ({site}
) > 1 THEN ‘Yes’
ELSE ‘No’ END AS i
FROM dbo.v_imItem w
WHERE itemClassId = :itemClassId
order by i desc, itemId ASC
I changed the parameter from querystring to value, and this works. Thanks.