jdbc - Java prepareStatement setting -


i have prepare statement this:

where  trade_date >= trunc(add_months(current_date,-12)) 

but want have this:

where  trade_date >= trunc(?) 

and set value later this:

query.setstring(1,"add_months(current_date,-12)"); 

or

query.setstring(1,"trunc(sysdate, 'year')"); 

however, got error saying

inconsistent datatypes: expected date got number 

how can that?

i think you'll have build template statement using string concatenation etc, , record parameters wish insert alongside (in array of objects?).

then iterate through each 1 , perform setstring() etc. can't insert arbitrary sql using preparedstatement (it defeat 1 of preparedstatement's benefits, restrict sql construction customising parameters)


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -