Was this helpful?
Variable Usage
After host language variables are declared, use them in your embedded statements. In embedded SQL 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 language variable can have the same name as a database object, such as a column. The preceding colon distinguishes the variable from an object of the same name.
If no value is returned (for example, no rows qualified in a query), the contents of the variable are not modified.
Last modified date: 04/03/2024