Four types of dynamic
SQL are available.
- Embedded dynamic SQL
- Your application
puts the SQL source in host variables and includes
PREPARE and EXECUTE statements that tell DB2® to
prepare and run the contents of those host variables at run time.
You must precompile and bind programs that include embedded dynamic
SQL.
- Interactive SQL
- A user enters
SQL statements through an interactive tool, such
as DB2 QMF™ for Windows®. DB2 prepares and executes those
statements as dynamic SQL statements.
- Deferred
embedded SQL
- Deferred embedded SQL statements are neither
fully static nor
fully dynamic. Like static statements, deferred embedded SQL statements
are embedded within applications; however, like dynamic statements,
they are prepared at run time. DB2 processes
the deferred embedded SQL statements with bind-time rules. For example, DB2 uses the authorization ID and
qualifier (that are determined at bind time) as the plan or package
owner.
- Dynamic SQL executed through ODBC
or JDBC functions
- Your application contains ODBC function
calls that pass dynamic
SQL statements as arguments. You do not need to precompile and bind
programs that use ODBC function calls.
- JDBC application support
lets you write dynamic SQL applications
in Java™.