Common concepts and rules for using embedded SQL
Here are some common concepts and rules for using SQL statements in a host language.
- Writing applications that use SQL
You can create database applications in host languages that use DB2 for i SQL statements and functions. - Using host variables in SQL statements
When your program retrieves data, the values are put into data items that are defined by your program and that are specified with the INTO clause of a SELECT INTO or FETCH statement. The data items are called host variables. - Handling SQL error return codes using the SQLCA
When an SQL statement is processed in your program, SQL places a return code in the SQLCODE and SQLSTATE fields. The return codes indicate the success or failure of the running of your statement. - Using the SQL diagnostics area
The SQL diagnostics area is used to keep the returned information for an SQL statement that has been run in a program. It contains all the information that is available to you as an application programmer through the SQLCA. - Handling exception conditions with the WHENEVER statement
The WHENEVER statement causes SQL to check the SQLSTATE and SQLCODE and continue processing your program, or branch to another area in your program if an error, exception, or warning exists as a result of running an SQL statement.
Parent topic: Embedded SQL programming