Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-6336

When inserting an insert SQL statement containing non-ANSII characters into an Oracle database, an exception occurs

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.36.0
    • None
    • core
    • None

    Description

      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

      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("')");
          }
      } 

      Attachments

        Activity

          People

            Unassigned Unassigned
            gundamveda gunveda
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: