SQL programming / SQL portability |
Make sure that SQL statement syntaxes are supported by all target database engines.
Several SQL syntaxes for the INSERT, UPDATE and DELETE statements are supported by the compiler. Some of the syntaxes are IBM® Informix® specific, but will be converted to standard SQL at compile time.
(1) INSERT INTO table (column-list) VALUES (value-list) (2) UPDATE table SET column = value, ... [WHERE condition] (3) DELETE FROM table [WHERE condition]
(4) INSERT INTO table VALUES record.* -- where record is defined LIKE a table from db schema (5) UPDATE table SET (column-list) = (value-list) [WHERE condition] (6) UPDATE table SET {[table.]*|(column-list)} = record.* ... [WHERE condition] -- where record is defined LIKE a table from db schema
(7) UPDATE table SET [table.]* = (value-list) [WHERE condition]
You can easily search for non-portable SQL statements in your sources by compiling with the -W stdall fglcomp option.
For maximum SQL portability, INSERT statements should be reviewed to avoid the SERIAL column from the value list.
INSERT INTO tab (col1, col2, ...) VALUES ( 0, p_value2, ... )
INSERT INTO tab (col2, ...) VALUES ( p_value2, ... )
DEFINE rec LIKE tab.* INSERT INTO tab VALUES ( rec.* ) -- will use the serial column
INSERT INTO tab VALUES rec.* -- without braces, serial column is removed
For more details about supported SQL DML statements, see static SQL.