SQL Programming Manual for Pascal

Program Compilation and Execution
HP NonStop SQL Programming Manual for Pascal528614-001
5-15
Running the SQL Compiler
Error Conditions. An error condition results from an invalid reference to an SQL
object in an SQL statement. Examples of invalid references are incorrect column
names or incompatible data types. If an error occurs, the SQL compiler produces a
listing, but it does not record the program file in the catalog and does not validate it for
execution.
Dynamic SQL statements are not compiled during explicit SQL compilation. These
statements are compiled at run time by the execution of a PREPARE statement, which
returns a run-time error if invalid syntax or an invalid reference occurs.
You can force the SQL compilation regardless of errors. To force compilation, specify
the FORCE option in the SQLCOMP command. If you use the FORCE option, the
compiler records the SQL object program file in the catalog and validates the program
file for execution even if errors occur.
The SQL compiler also writes the SQL source statements with errors to the object
program file so that the statements can be automatically recompiled if executed at run
time. Any error that exists at explicit SQL compilation time is also an error at run time.
Usually, the FORCE option is useful to debug programs when you are not concerned
about executing the SQL statements that produce errors.
Warning Conditions. A warning condition usually occurs when the SQL compiler has
insufficient information available. If warnings occur, the SQL compiler still records the
program file in the catalog and validates the file for execution and then returns a
warning message. The following paragraphs describe some of the conditions that
cause warnings.
In the following two cases, the SQL compiler issues a warning message but still
compiles the statement:
Compiler assumptions
The compiler made an assumption necessary to complete the compilation. For
example, if the number of columns in the SELECT statement does not match the
number of host variables, the compiler reports a warning message and assumes
that you do not want to use either the extra columns or the extra host variables.
Unavailable statistics
The compiler did not have the necessary statistics for tables to optimize an
execution plan. The compiler uses statistics in the catalog in which a table or view
is registered to determine an optimized execution plan. These statistics are usually
generated by a database administrator running the UPDATE STATISTICS
statement on tables.
In other cases, the SQL compiler first marks the statement as having insufficient
information to compile and then at run time tries to resolve the problem with automatic
recompilation. The SQL compiler does not record dependencies in the USAGES
catalog tables for the affected statement. At run time, if the necessary information is
still not available or the DEFINEs are still unresolved, execution of the statement
causes an error. These cases are: