Precompiler-detected errors

The Embedded SQL precompiler detects Embedded SQL errors at precompile time. The precompiler detects syntax errors such as missing semicolons and undeclared host variables in SQL statements. These are severe errors, so appropriate error messages are generated.

You can also have the precompiler check Transact-SQL syntax errors. Adaptive Server parses Transact-SQL statements at precompile time if the appropriate precompiler command options are set. See the precompiler reference page in the Open Client and Open Server Programmer’s Supplement.

The precompiler substitutes host variables in Embedded SQL statements with dynamic parameter markers (“?”). Occasionally, substituting host variables with parameter markers causes syntax errors (for example, when rules or triggers do not allow the parameters).

The precompiler does not detect the error in the following example, in which a table is created and data is selected from it. The error is that the host variables’ datatypes do not match the columns retrieved. The precompiler does not detect the error because the table does not yet exist when the precompiler parses the statements:

exec sql begin declare section end-exec 
         01  VAR1           PIC S9(9) COMP. 
         02  VAR2           PIC X(20). 
         exec sql end declare section end-exec 
  
         exec sql create table T1  
           (col1 int, col2 varchar(20)) end-exec 
         ... 
  
         exec sql select * from T1 into
        :VAR2, :VAR1 end-exec. 

Note that the error will be detected and reported at runtime.