SQL Programming Manual for TAL

Program Compilation and Execution
HP NonStop SQL Programming Manual for TAL527887-001
5-14
Running the SQL Compiler
Interpreting SQL Compiler Messages
The SQL compiler issues messages for error and warning conditions. An error can
prevent successful compilation of a program file, but a warning does not prevent
successful compilation. For a description of SQL compiler messages, see the
SQL/MP
Messages Manual.
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 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 FORCE option is sometimes useful for
program debugging when you are not concerned about executing the SQL statements
that produce errors.
The SQL compiler also writes the SQL source statements that have errors to the object
file so that the statements can be automatically recompiled if executed at run time.
Warning Conditions. A warning condition usually occurs when the SQL compiler has
insufficient information available. If a warning occurs, 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 these 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 returns 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.