String delimiters
Informix®
The ANSI SQL string delimiter character is the single quote ('string'
), while
double quotes are used to delimit database object names:
SELECT ... WHERE "tabname"."colname" = 'a string value'
SELECT ... WHERE tabname.colname = 'a string value'
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.
Dameng®
Dameng follows the ANSI SQL specification, using single quotes for string delimiters and double quotes for database object names.
Solution
$ cat s.4gl
MAIN
DEFINE n INT
SELECT COUNT(*) INTO n FROM tab1 WHERE col1 = "abc"
END MAIN
$ fglcomp -S s.4gl
s.4gl^3^SELECT COUNT(*) FROM tab1 WHERE col1 = 'abc'
However, SQL statements created dynamically are not modified by the Genero compiler.
The Genero database interface can automatically replace all double quotes by single quotes in SQL statements. This applies to static and dynamic SQL statements.
dbi.database.dbname.ifxemul.dblquotes = {
true |
false }
For
more details see IBM Informix emulation parameters in FGLPROFILE.... WHERE "tabname"."colname" = "a string value"
... WHERE 'tabname'.'colname' = 'a string value'
This would produce an error since 'tabname'.'colname' is not allowed by ORACLE.
Escaped string delimiters can be used inside strings like the following:
'This is a single quote: '''
'This is a single quote: \''
"This is a double quote: """
"This is a double quote: \""
Although double quotes are replaced automatically in SQL statements, it is recommended that you use only single quotes to enforce portability.