Variable Usage
Pascal variables declared to Embedded SQL can substitute for most non key-word elements of Embedded SQL statements. Of course, the variable and its data type must make sense in the context of the element. To use a Pascal variable (or named constant) in an Embedded SQL statement, you must 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 "idnovar" as an expression in the where clause:
exec sql select name, num
into :namevar, :numvar
from employee
where idno = :idnovar;
You should not use the Pascal type-cast operator (::) in Embedded SQL statements. The preprocessor ignores it and does not change the type of the variable.
Various rules and restrictions apply to the use of Pascal variables in Embedded SQL statements. The sections below describe the usage syntax of different categories of variables and provide examples of such use.