<insert>

The <insert> element allows you to place a <block> of Macro Language code into the Macro Language query you are currently working in, as well as access the encapsulating <block>'s variables.

Description

The <block> you <insert> must be defined in your current query or in a <library>. A <library> can be defined in your current query or stored as part of a Quick Query. If you need a <block> from a <library> defined outside your current query, you must use <import> to make that library available in your current query.

<insert> allows you to access, but not modify, the encapsulating <block>'s variables or values. <insert> differs from <call> in that <call> does not have any access to the encapsulating block's variables. If you want to be able to both access and modify the encapsulating <block>'s variables, use <expand>.

Syntax

<insert block="[NAME_OF_BLOCK]" [[VAR_1]="[VALUE_1]"
        [VAR_2]="[VALUE_2]"...
        [VAR_N]="[VALUE_N]"]/>

Attributes

block
Specifies the <block> (code and defined variables) to insert into the current query.

The <insert> tag may take any number of additional attributes, which should match the attributes in the <block> tag that defines the inserted block. The [VALUE] of a [VAR]="[VALUE]" attribute is substituted wherever {@[VAR]} appears within the inserted <block>.

Example

In this example, assume the base table is pub.demo.retail.item.

<base table="pub.demo.retail.item"/>
<library>
  <block name="storeSelection" storechoice="">
    <sel value="store={@storechoice}"/>
  </block>
</library>

<insert block="storeSelection" storechoice="3"/>

At the location of the <insert> statement, the <block> named storeSelection is expanded using the storechoice attribute, and the value for storechoice (3) is substituted for {@storechoice} within the <block>, effectively resulting in the following operation:

<sel value="store=3"/>