#sqlcompile mode
Description
This macro preprocessor directive is deprecated. At InterSystems IRIS 2020.1, Embedded SQL code for most operations (including SELECT, INSERT, UPDATE, and DELETE) is compiled when the SQL code is executed (runtime), not when the routine containing this SQL code is compiled, regardless of the setting of this preprocessor directive.
In earlier releases, #sqlcompile mode=value specified the compilation mode for Embedded SQL in code subsequent to this preprocessor directive. It specified the compilation mode for certain Embedded SQL DML commands as either Embedded (process Embedded SQL at compile time) or Deferred (defer processing of Embedded SQL until runtime).
At InterSystems IRIS 2020.1, all Embedded SQL DML commands are deferred until runtime, at which time they are processed as cached queries. Therefore, Embedded SQL can always refer to tables, user-defined functions, and other SQL entities that do not yet exist at compile time.
An Embedded SQL statement is parsed at compile time. If it contains invalid SQL (for example, an SQL syntax error), the compiler generates the code "** SQL Statement Failed to Compile **" and continues to compile ObjectScript code. Thus when compiling a class with a method that contains invalid embedded SQL, the SQL error is reported, but the method is generated. The invalid SQL causes an error when this method is run.
For further details, see Embedded SQL.
#sqlcompile mode=Deferred should not be confused with the similarly-name $SYSTEM.SQL.Util.SetOption(“CompileModeDeferred”) method, which is used for a completely different purpose.