The LET statement
With a LET statement, you can use one or more variable
names with an equal (=) sign and a valid expression or function name.
Each example in the following figure is a valid LET statement.
HCL Informix® allows you to assign a value to an opaque-type variable, a row-type variable, or a field of a row type. You can also return the value of an external function or another SPL function to an SPL variable.
Suppose
you define the named row types zip_t and address_t,
as Named and unnamed row variables. shows.
Anytime you define a row-type variable, you must initialize the variable
before you can use it. The following figure shows how you might define
and initialize a row-type variable. You can use any row-type value
to initialize the variable.
After you define and initialize the row-type variable,
you can write the LET statements that the following figure shows.
Tip: Use dot notation in the form variable.field or variable.field.field to
access the fields of a row type, as Handle row-type data describes.
Suppose you define an opaque-type point that contains two values that define a two-dimensional point, and the text representation of the values is '(x,y)'. You might also have a function circum() that calculates the circumference of a circle, given the point '(x,y)' and a radius r.
If you define an opaque-type center that
defines a point as the center of a circle, and a function circum() that
calculates the circumference of a circle, based on a point and the
radius, you can write variable declarations for each. In the following
figure, c is an opaque type variable and d holds the
value that the external function circum() returns.
The Informix® Guide to SQL: Syntax describes in detail the syntax of the LET statement.