Submitting SQL statements to DB2

You can use several different methods to send SQL statements to DB2® in several ways.

You can issue SQL statements from interactively from a keyboard at a terminal or through a terminal emulator.

Another way to issue SQL statements is through application programs. The programs can contain SQL statements that are statically embedded in the application. Alternatively, application programs can create their SQL statements dynamically, for example, in response to information that a user provides by filling in a form.

The method of preparing an SQL statement for execution and the persistence of its operational form distinguish static SQL from dynamic SQL.

Interactive SQL
Interactive SQL refers to SQL statements that you submit to DB2 by using SPUFI (SQL processor using file input), the command line processor, or by using query tools, such as DB2 Query Management Facility™ (QMF™).
Static SQL
The source form of a static SQL statement is embedded within an application program written in a host language such as COBOL. The statement is prepared before the program is executed and the operational form of the statement persists beyond the execution of the program.
Related information:
Dynamic SQL
You can use dynamic SQL when you do not know the content of an SQL statement when you write a program or before you run it.

You can issue dynamic SQL statements in the following contexts:

Start of changeYou can use IBM® pureQuery® to add static functionality to dynamic SQL. IBM pureQuery features an intuitive API and enables SQL access to databases or in-memory Java objects. You can also use pureQuery Runtime to enable flexible static SQL deployment for DB2.End of change

DB2 ODBC
DB2 ODBC (Open Database Connectivity) is an application programming interface (API) that enables C and C++ application programs to access relational databases
This interface offers an alternative to using embedded static SQL and a different way of performing dynamic SQL. Through the interface, an application invokes a C function at execution time to connect to a data source, to dynamically issue SQL statements, and to retrieve data and status information.
DB2 access for Java: SQLJ, JDBC and pureQuery
SQLJ, JDBC, and pureQuery are methods for accessing DB2 data from applications that are written in the Java programming language.

In general, Java applications use SQLJ for static SQL, and they use JDBC for dynamic SQL. IBM pureQuery provides benefits to both static and dynamic SQL.