6. Embedded SQL for BASIC : BASIC Variables and Data Types : Variable Usage
 
Share this page                  
Variable Usage
BASIC variables declared in an Embedded SQL declaration section 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. When you use a BASIC variable in an Embedded SQL statement, you must precede the variable 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:
exec sql select ename, eno        &
    into :namevar, :numvar        &
    from employee                 &
    where eno = :idno
Various rules and restrictions apply to the use of BASIC variables in Embedded SQL statements. The sections below describe the usage syntax of different categories of variables and provide examples of such use.