Apostrophes and quotation marks as string delimiters

SQL processing options and DB2® installation panel fields control the representation of string delimiters in COBOL and SQL statements.

The following SQL processing options control the representation of string delimiters:

  • APOST and QUOTE are mutually exclusive SQL processing options for COBOL. Their meanings are exactly what they are for the COBOL compilers:
    • APOST names the apostrophe (') as the string delimiter in COBOL statements.
    • QUOTE names the quotation mark (") as the string delimiter.

    Neither option applies to SQL syntax. Do not confuse them with the APOSTSQL and QUOTESQL options.

  • APOSTSQL and QUOTESQL are mutually exclusive SQL processing options for COBOL. Their meanings are:
    • APOSTSQL names the apostrophe (') as the string delimiter and the quotation mark (") as the escape character in SQL statements.
    • QUOTESQL names the quotation mark (") as the string delimiter and the apostrophe (') as the escape character in SQL statements.

These values apply to SQL statements as follows:

  • For a distributed operation, the string delimiter is the first of the following values that applies:
    • The SQL string delimiter value specified by the requester
    • The value of the field SQL STRING DELIMITER on installation panel DSNTIPF at the DB2 where the package is bound
  • Otherwise:
    • For static SQL statements:

      In a COBOL program, the SQL processing option APOSTSQL or QUOTESQL determines the string delimiter and escape character. If neither SQL processing option is specified, the value of field SQL STRING DELIMITER on installation panel DSNTIPF determines the string delimiter and escape character.

      In a non-COBOL program, the string delimiter is the apostrophe, and the escape character is the quotation mark.

    • For dynamic SQL statements:
      • If DYNAMICRULES run behavior applies, the string delimiter and escape character is the value of field SQL STRING DELIMITER on installation panel DSNTIPF at the local DB2 when the statement is prepared.

        For a list of the DYNAMICRULES option values that specify run, bind, define, or invoke behavior, see Table 1.

      • If DYNAMICRULES bind, define, or invoke behavior applies and the value of installation panel field USE FOR DYNAMICRULES is YES, the string delimiter and escape character is the value of field SQL STRING DELIMITER.

        If bind, define, or invoke behavior applies and USE FOR DYNAMICRULES is NO, the SQL processing option determines the string delimiter and escape character. For COBOL programs, SQL processing option APOSTSQL or QUOTESQL determines the string delimiter and escape character. If neither SQL processing option is specified, the value of field SQL STRING DELIMITER determines them. For programs written in other host languages, the default SQL processing option, which can only be APOSTSQL, determines the string delimiter and escape character.