SQL keyword protection
If the code in the files
is passed unprotected to the C preprocessor before it is passed to
the preprocessor,
certain SQL keywords might be analyzed by the C preprocessor, which
causes unintended results. In the following example, the SQL keyword
NULL is replaced by the C preprocessor with the value zero, which
creates a valid SQL statement, but one which inserts a value into
the orders table other than the value that the programmer intended:
EXEC SQL insert into orders (shipcharge) values (NULL);
When a user gives the option to run the C preprocessor before the preprocessor,
the utility eprotect runs before the C preprocessor runs on
the source
file. The eprotect utility adds a prefix to any
SQL keyword that occurs in an SQL statement with the prefix SQLKEYWORD_.
This prefix is affixed on all SQL keywords inside SQL statements that
begin with the EXEC SQL directive and end with a semicolon. When the source
file that contains the select statement mentioned earlier is passed
to the C preprocessor, the SELECT statement has the following form:
EXEC SQL SQLKEYWORD_insert SQLKEYWORD_into orders (order_num)
SQLKEYWORD_values (SQLKEYWORD_NULL);
After the C preprocessor runs on the source file, the esql command runs the eprotect utility with the -u mode, which removes all the SQLKEYWORD_ prefixes before it runs the preprocessor on the output of the C preprocessor.