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 schema is SYSIBM.
- integer-constant
- An integer constant that specifies a position index of a value in the arguments of db2-fn:sqlquery.
The value must be between 1 and the total number of the arguments specified in the db2-fn:sqlquery SQL statement (SQLSTATE 42815).
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).
Example
In the following example, the db2-fn:sqlquery function call uses one PARAMETER function call and the XQuery expression <>$po/@OrderDate, the order date attribute.
The PARAMETER function call returns the value of order date attribute:
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.
© Copyright IBM Corp.