5. Embedded QUEL for Ada : Ada Variables and Data Types : Variable Usage
 
Share this page                  
Variable Usage
Ada variables declared to EQUEL can substitute for most elements of EQUEL statements that are not keywords. Of course, the variable and its data type must make sense in the context of the element. To use an Ada variable in an EQUEL statement, just use its name. To refer to an element, such as a database column, with the same name as a variable, dereference the element by using the EQUEL dereferencing indicator (#). As an example of variable usage, the following retrieve statement uses the variables "namevar" and "numvar" to receive data, and the variable "idnovar" as an expression in the where clause:
## retrieve (namevar = e.name, numvar = e.num)
## where e.idno = idnovar;
When referencing a variable, you cannot use an Ada attribute, because the attribute is introduced by a single quote. EQUEL will treat this single quote as the beginning of a string literal and will generate a syntax error.
When referencing a variable, you also cannot use the dotted notation to refer to hidden or ambiguous objects by prefixing the object with a subprogram or package name, even if the package is explicitly declared. EQUEL will generate a syntax error on the qualifying dot.
If, in retrieving from Ingres into a program variable, no value is returned for some reason (for example, no rows qualified in a query), the variable will contain an undefined value.
Various rules and restrictions apply to the use of Ada variables in EQUEL statements. The sections below describe the usage syntax of different categories of variables and provide examples of such use.