Problem:
When you read a variable which contains double quotes e.g. <a href="abc.pdf">test</a>
and you try to save it in a database column of type varchar, you will get an error similar to the one below:
Error: [pdq][10107][2.7.116] An error prevented the update operation from completing successfully.; Caused by: com.ibm.db2.jcc.am.io: [jcc][1091][10404][3.57.82] Invalid data conversion: Parameter instance <a href="abc.pdf">test</a> is invalid for the requested conversion. ERRORCODE=-4461, SQLSTATE=42815 ]
Resolution:
You need to escape the double quotes as shown below before trying to store the variable in database to avoid the error.
def link = zget("/request/params/link");
if(link !=null){
link=link.replaceAll('"','\\"');
}
No comments:
Post a Comment