I have some SQL strings with parameters from a log file such as
select a,b,c from db_table where d=? and e=?
-> params: [10,20]
I can not change the log format such that the question marks are replaced by the respective parameters (at least not as far as I know, I'm using Toplink as an OR mapper). So I would like to have a little utility that I can give the query, the pattern and the parameters and it gives me the result (GUI or no doesn't matter). Something like this:
> insertUtil 'select a,b,c from db_table where d=? and e=?' '?' '10,20'
select a,b,c from db_table where d='10' and e='20'
It doesn't have to be perfect (e.g. date conversions etc.), it should just insert the strings. No need to prevent SQL injection, it's just a tool for debugging the potentially long queries.
I know it's trivial to program such a thing but I'm surprised I could not find any existing program like that.
To make it clear I'm not looking for a way to make prepared statements with JDBC, I'm trying to get that complete query including parameters so I can execute it in another program, for example to generate a query plan for it.