A variable reference is a string that htmSQL replaces with the value
of a variable. Variables are symbols that are defined on the URL,
columns that are selected by a query, or
symbols
that htmSQL automatically defines and supplies values for.
When htmSQL encounters
a variable reference, it replaces the reference with the current value
of the variable. If the reference is to a column in a results set
and
-
the variable reference occurs before
the SQL section, then the variable is undefined and cannot be resolved.
The variable reference is written to
stdout
unresolved.
-
the variable reference occurs between
the SQL section and the eachrow section, then htmSQL replaces the
variable reference with the variable's value from the first row of
the results set.
-
the variable reference occurs within
an eachrow section, then htmSQL replaces the variable reference with
the current row's value for the variable.
-
the variable reference occurs after
the eachrow section, then htmSQL replaces the variable reference with
the variable's value from the last row of the results set.
htmSQL also supports
the resolution of nested variable references. That is, the value of
a variable can itself be a variable that htmSQL can resolve. For example,
if you have a variable named taxi, and the value of taxi is the variable
name driver,
{&taxi} -----> driver
and the value of driver is
Bob
,
{&driver} -----> Bob
then when you specify
{&{&taxi}}
, htmSQL resolves the nested references
to a value of
Bob
.
{&{&taxi}} -----> Bob
htmSQL can resolve an infinite number of these nested variable references.