All,
I am storing SQL queries as XML for my java application to improve maintainability.
Parts of my query require parameterisation, therefore I have created identifiers that I can use to replace with values when I create my query string.
e.g.
WHERE CB.callback_date >= TO_DATE('$LASTDATE$','DD/MM/YYYY')
AND CB.callback_date < TO_DATE('$FROMDATE$','DD/MM/YYYY')
I have a function in my application that will replace these substrings.
public static String xmlQueryPrep(String prep)
{
//add dates to query
prep.replace("'$LASTDATE$'", "'20/10/2013'");
prep.replace("'$FROMDATE$'", "'18/10/2013'");
prep.replace("<", "<").replace(">", ">");
return prep;
}
For some reason it is replacing the ASCII codes for < and > but it is not replacing my markup
Output
WHERE CB.callback_date >= TO_DATE('$LASTDATE$','DD/MM/YYYY')
AND CB.callback_date < TO_DATE('$FROMDATE$','DD/MM/YYYY')
Why is it not replacing correctly?