Variable Usage
After host language variables are declared, they can be used in embedded statements. Host language variables must be preceded by a colon. For example:
exec sql select ename, sal
into :name, :salary
from employee
where eno = :empnum;
The INTO clause contains two host language variables, name and salary and the WHERE clause contains one, empnum.
A host variable can have the same name as a database object, such as a column. The preceding colon distinguishes the variable from a database object of the same name.
If the application issues a query intended to retrieve values from a table into a host variable and the query returns no value (for example, no row in the table fulfilled the query), the contents of the variable are not modified.
Last modified date: 08/28/2024