<let>
<let> is used within a <block>, or
independently in place of a <block>, and can be used to assign new values to
variables defined within the block or to define new variables.
Description
The form <let [VAR_1]="A"
[VAR_2]="B"> [CONTENTS] </let> expands
[CONTENTS] with [VAR_1] and
[VAR_2] defined. The values of these variables may be referenced (along
with other block variables) with the {@[VAR]} syntax
within expressions in [CONTENTS].
Variables defined within a <let> only have scope within the
<let></let> element itself.
<let> element can be used in the same way a
<block> is used, only without the
name="[BLOCK_NAME]" portion of the opening
tag.Syntax
<let [USER_DEFINED_VAR_1]="[VALUE_1]" ...
[USER_DEFINED_VAR_N]="[VALUE_N]">
[CONTENTS]
</let>
Attributes
[USER_DEFINED_VAR_x]- Accepts a string that will act as a user-defined variable. The variable name must
begin with a lowercase alphabetic character and consist only of lowercase alphanumeric
characters, digits, and/or underscores.
The block element may include any number of additional attributes, which may be used as parameters in the Macro Language code contained within the element. The value of a user-defined variable (e.g.,
my_var) is substituted wherever a scalar expression containing a reference to it (e.g.,{@my_var}) appears within the block element.
Example
In this example, the base table is pub.demo.retail.item. The goal is to parameterize a selection statement so that both the column and the comparison value can be provided independently of the selection statement itself.
<base table="pub.demo.retail.item"/> <let column="sales" val="1.25"> <sel value="{@column}>{@val}"/> </let>
This query expands to:
<sel value="sales>1.25"/>
