Before you start
This tutorial introduces you to embedded SQL programming and walks you through the basic steps of constructing an embedded SQL application. This tutorial also provides you an introduction to converting one or more high-level programming language source code files containing embedded SQL into an executable application. In this tutorial, you will learn:
- How SQL statements are embedded in a high-level programming language source code file
- The steps involved in developing an embedded SQL application
- What host variables are, how they are created, and how they are used
- What indicator variables are, how they are created, and when they are used
- How to analyze the contents of an SQLCA data structure variable
- How to establish a database connection from an embedded SQL application
- How to capture and process errors when they occur
- How to convert source code files containing embedded SQL into an executable application
This is the fourth in a series of nine tutorials designed to help you prepare for the DB2 Application Developer Certification exam (Exam 733). The material in this tutorial covers the objectives in Section 4 of the exam, entitled "Embedded SQL programming." You can view these objectives at http://www.ibm.com/certify/tests/obj733.shtml.
You do not need a copy of DB2 Universal Database to complete this tutorial. However, you can download a free trial version of IBM DB2 Universal Database Enterprise Edition, and a free copy of DB2 Express-C 9 from the DB2 Express-C downloads page.
After completing this tutorial, you should be able to:
- Establish a database connection within an embedded SQL application
- Execute SQL statements within an embedded SQL application
- Analyze results and handle common errors encountered when SQL statements are executed in an embedded SQL application
To understand some of the material presented in this tutorial, you should be familiar with the following terms:
-
Object: Anything in a database that can be created or manipulated with SQL (for example tables, views, indexes, and packages).
-
Table: A logical structure used to present data as a collection of unordered rows with a fixed number of columns. Each column contains a set of values, each value of the same data type (or a subtype of the column's data type); the definitions of the columns make up the table structure, and the rows contain the actual table data.
-
DB2 optimizer: A component of the SQL precompiler that chooses an access plan for a Data Manipulation Language (DML) SQL statement by modeling the execution cost of several alternative access plans and choosing the one with the lowest estimated cost.





