SQL programming / SQL portability |
Single quotes is the standard for delimiting string literals in SQL.
SELECT COUNT(*) FROM table WHERE col1 = "abc'def""ghi" AND col1 = 'abc''def"ghi'
Most database servers do not support this specific feature.
Database Server Type | Double quoted string literals |
---|---|
Genero db | No |
IBM DB2® UDB | No |
IBM Informix | Yes |
Microsoft™ SQL Server | Yes |
MySQL | No |
Oracle Database Server | No |
PostgreSQL | No |
Sybase ASE | No |
SQLite | Yes |
CREATE TABLE "my table" ( "column 1" CHAR(10) ) SELECT COUNT(*) FROM "my table" WHERE "column 1" = 'abc'
... WHERE comment = 'John''s house'
When writing static SQL in your programs, the double quoted string literals as converted to ANSI single quoted string literals by the fglcomp compiler. However, dynamic SQL statements are not parsed by the compiler and therefore need to use single quoted string literals.
We recommend that you always use single quotes for string literals and, if needed, double quotes for database object names.