The PARAMETER function represents a position in an SQL statement where the value is provided dynamically by XQuery as part of the invocation of the db2-fn:sqlquery function.
>>-PARAMETER--(--integer-constant--)---------------------------><
The schema is SYSIBM.
The PARAMETER function represents a position in an SQL statement where the value is provided dynamically by XQuery as part of the invocation of the db2-fn:sqlquery function. The argument of the PARAMETER function determines which value is substituted for the PARAMETER function when the db2-fn:sqlquery function is executed. The value supplied by the PARAMETER function can be referenced multiple times within the same SQL statement.
This function can only be used in a fullselect contained in the string literal argument of the db2-fn:sqlquery function in an XQuery expression (SQLSTATE 42887).
xquery
declare default element namespace "http://posample.org";
for $po in db2-fn:xmlcolumn('PURCHASEORDER.PORDER')/PurchaseOrder,
$item in $po/item/partid
for $p in db2-fn:sqlquery(
"select description from product where promostart < PARAMETER(1)",
$po/@OrderDate )
where $p//@pid = $item
return
<RESULT>
<PoNum>{data($po/@PoNum)}</PoNum>
<PartID>{data($item)} </PartID>
<PoDate>{data($po/@OrderDate)}</PoDate>
</RESULT>
The example returns the purchase ID, part ID, and the
purchase date for all the parts sold after the promotional start date.