0

I'm using PostgreSQL's function query_to_xml function to generate XML of a query result.

SELECT * FROM query_to_xml( 'SELECT * from some_table WHERE id = ?',true,false,'')

Problem is, when I use it from JDBC, with prepared Statements the '?' is ignored, so Postgres says:

"The column index is out of range..."

Is there any possible solution to pass parameters to such a query ?

0

1 Answer 1

2

Try to move the ? outside the string literal:

SELECT * FROM query_to_xml( 'SELECT * from some_table WHERE id = '||?,true,false,'')
Sign up to request clarification or add additional context in comments.

2 Comments

thanks, that works out! I suppose, even if I need an ORDER BY, i can concat it by || ?
I think you'd write: ..WHERE id= '||?||' ORDER BY...',true,...,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.