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 PostgreSQL doesn't. This is important since many BDL programs use that character to delimit the strings in SQL commands.

Note: 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 PostgreSQL database interface can automatically replace all double quotes by single quotes.

Escaped string delimiters can be used inside strings like 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 PostgreSQL.

Although double quotes are replaced automatically in SQL statements, you should use only single quotes to enforce portability.