gunveda created CALCITE-6336:
--------------------------------
Summary: When inserting an insert SQL statement containing
non-ANSII characters into an Oracle database, an exception occurs
Key: CALCITE-6336
URL: https://issues.apache.org/jira/browse/CALCITE-6336
Project: Calcite
Issue Type: Bug
Components: core
Affects Versions: 1.36.0
Reporter: gunveda
*The following content is a Chinese translation*
Use the u& prefix for non-ANSII characters. This method is not supported in
Oracle, and should be replaced with the unistr function.
Modify as follows
{code:java}
public class CustomOracleSqlDialect extends OracleSqlDialect {
private static final char[] HEXITS = {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f',
};
public static final SqlDialect DEFAULT = new
CustomOracleSqlDialect(DEFAULT_CONTEXT);
public CustomOracleSqlDialect(Context context) {
super(context);
}
@Override
public void quoteStringLiteralUnicode(StringBuilder buf, String val) {
buf.append("unistr('");
for (int i = 0; i < val.length(); i++) {
char c = val.charAt(i);
if (c < 32 || c >= 128) {
buf.append('\\');
buf.append(HEXITS[(c >> 12) & 0xf]);
buf.append(HEXITS[(c >> 8) & 0xf]);
buf.append(HEXITS[(c >> 4) & 0xf]);
buf.append(HEXITS[c & 0xf]);
} else if (c == '\'' || c == '\\') {
buf.append(c);
buf.append(c);
} else {
buf.append(c);
}
}
buf.append("')");
}
} {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)