Parametrized load queries and scripts
In the Staging database, you can use parameters in load queries and scripts. In the
Integration database, you can use parameters in load queries.
In addition, if you use custom settings in load queries, those settings are automatically translated to SQL parameters.
Parameters can be of these data types:
- Text
- Number
- Date/Time
- Boolean
Reference single-value parameters with @[parameter_name]
.
Reference multi-value parameters with @@[parameter_name]
. Values in
multiple-value parameters must be separated by the pipe (|)
character.
Parametrized load query
You have a table called Drink_Sales in the Staging database. It holds sales of several drinks. When you load data, you specify which drink is referenced by the parameter.
- Create a load query called
LoadDrinkSales
. - Create a parameter called pProduct.
- Specify your load query with this
syntax:
Select * from Drink_Sales where Drink=@pProduct
If the parameter is multi-value, specify:
.Select * from Drink_Sales where Drink IN (@@pProduct)
This is the same syntax as is used in Application Studio relational lists.
- Click .
- In the Load Query Parameters dialog box, specify the values for the
parameter. To specify multiple values, separate them with the pipe (
|
) character.
Note: If a parameter is not referenced in a load query
or script, then you can leave it empty. But if a parameter is referenced, then you must
provide a value. Leaving a used parameter empty does not send NULL or an empty
string.
Parametrized script
This example references a parameter to delete a row from the Drink_Sales table.
- Create a script called DeleteDrinkSales.
- Create a parameter called pProduct.
- Specify your script with this
syntax:
Delete from Drink_Sales where Drink=@pProduct