Hi,
I can create a a block of code like this and it will work:
DECLARE @id varchar(50)
SET @id = 'bla'
SELECT RECID FROM MYTABLE WHERE "MYCOL".exist('//c3[text()=(sql:variable("@id"))]' ) = 1
But how do I get the same with a jdbc prepared statement without using the above DECLARE/SET? I've tried:
SELECT RECID FROM MYTABLE WHERE "MYCOL".exist('//c3[text()=(sql:variable(?))]' ) = 1
SELECT RECID FROM MYTABLE WHERE "MYCOL".exist('//c3[text()=?]' ) = 1
I want to bind the ? char above with 'bla'. The issue seems to be that the ? char is in the middle of the XQuery and isn't getting bound correctly. Is this DECLARE/SET mandatory in this situation or is there a clever way to do it like Oracle would, ie:
SELECT RECID FROM MYTABLE WHERE XMLEXISTS('$t[c3/text()=$id]' PASSING "MYCOL" as "t", CAST(? AS VARCHAR(4000)) as "id")
where I can bind the ? char with PreparedStatement.setString(1,'bla') without any DECLARE/SET syntax.
Thanks for any help!