String delimiters

The ANSI string delimiter character is the single quote ( 'string'). Double quotes are used to delimit database object names ("object-name").

Example: WHERE "tabname"."colname" = 'string'

Informix® allows double quotes as string delimiters, but IBM® DB2® doesn't. This is important since many BDL programs use that character to delimit the strings in SQL commands.

This problem concerns only double quotes within SQL statements. Double quotes used in pure BDL string expressions are not subject to SQL compatibility problems.

Solution

The IBM DB2 database interface can automatically replace all double quotes by single quotes. However, we recommend that you use only single quotes to enforce portability.

Escaped string delimiters can be used inside strings as in the following:

'This is a single quote: '''
'This is a single quote: \''
"This is a double quote: """
"This is a double quote: \""

Database object names cannot be delimited by double quotes because the database interface cannot determine the difference between a database object name and a quoted string!

For example, if the program executes the SQL statement:

WHERE "tabname"."colname" = "string"

replacing all double quotes by single quotes would produce:

WHERE 'tabname'.'colname' = 'string'

This would produce an error since 'tabname'.'colname' is not allowed by IBM DB2.