Implementing static SQL in DB2
When the complete SQL statement is known at pre-compile time, it is known as static SQL. All aspects of the SQL statement, such as the table name, column names, filter criteria, and so on must be specified at pre-compile time. The only thing that can be passed at the time of execution are host variables. Even if we have host variables, the complete information such as data type, length, and so on, must be available at the pre-compile time. Static SQL statements can be embedded in all languages except interpreted languages. At the time of pre-compilation, the language pre-processor converts the static SQL code into database manager run-time service API calls which the compiler can understand. In the case of interpreted languages, there is no concept of pre-processing, so everything becomes dynamic SQL there. In this section, we will see how to implement static SQL.
The advantages of static SQL are:
Relatively simpler programming effort
End user doesn't need...