2. Embedded SQL for C : C Variables and Data Types : Variable Usage
 
Share this page                  
Variable Usage
C variables that you declare in an embedded SQL declaration section can substitute for most elements of embedded SQL statements that are not keywords. Of course, the variable and its data type must make sense in the context of the element. When you use a C variable in an embedded SQL statement, precede it with a colon. You must further verify that the statement using the variable is in the scope of the variable's declaration. As an example, the following select statement uses the variables namevar and numvar to receive data, and the variable idno as an expression in the where clause.
Example: C variables usage
exec sql select ename, eno
       into :namevar, :numvar
       from employee
       where eno = :idno;
Various rules and restrictions apply to the use of C variables in embedded SQL statements. The following sections describe the usage syntax of different categories of variables and provide examples of such use.