Support Article
String with backslash causes database exception
SA-20168
Summary
Whenever a SQL insert statement contains a backslash character, in the values to be inserted; but PRRuntime exception is thrown and the database insert fails.
Error Messages
Caused by: com.pega.pegarules.data.internal.access.rdb.TokenMgrError: Lexical error at line 1, column 303. Encountered: " " (32), after : "\\"
Steps to Reproduce
1. Create an activity
2. Add a java step.
3 Put the below example code in the java step:
String aSQL = "INSERT INTO {Class:XYZ-FW-RQSFW-Work-ABCDapp} (PZINSKEY, TESTPROPERTY) values ('123', 'test\\ dbtest test')";
ClipboardPage aList = tools.createPage("Code-Pega-List", "");
aList.putString("pyObjClass", "Work-");
aList.putString("pyMaxRecords", "0");
int returnVal= 0;
try {
returnVal = tools.getDatabase().executeRDB(aSQL, aList);
}
catch (DatabaseException e) {
oLog.error("Error in insert", e);
}
Note: Here TESTPROPERTY is a property created on the example work class and is exposed.
4. Execute the activity and check logs.
Root Cause
A defect in Pegasystems’ code or rules.
Resolution
HFix-25399 resolves this issue.
Published March 1, 2016 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.