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 for your platform.

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;  
 CS_INT   var1;  
 CS_CHAR  var2[20]; 
 exec sql end declare section; 
  
 exec sql create table
     T1 (col1 int, col2 varchar(20)); 
 .... 
  
 exec sql select * from T1 into :var2, :var1;

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