IDE & Navigation
Properties & Tools
Dataset tag defines a data set which stores rows of data to be retrieved later by mscript function $getData('dsID','fieldName').
Before the dataset can be used, it must be declared and populated data from a data source.
Example model: Example_DataSet
The syntax to declare a dataset is:
<dataset id="datasetid" db="dbid" mode="replace/append" autorewind="true/false"/>
autorewind attribute is used to automatically start at the first row when all rows have been retrieved.
The mode attribute is used to append the new data to the data set or to clear the old data and replace them with the new data.
Although dataset tag may be placed any mscript triggers, it is most often placed in MbT_Trigger which is executed at the beginning of the model execution and it is executed only once per model execution.
If dataset tag is executed multiple times, the recent execution overrides the previous.
Once dataset is declared you can populate dataset with the data from external data sources.
There are three ways to populate the data set with rows of data.
Before you can use dataset, you must call by calling mscript function $loadFromDataSource('dsID','param1',...).
When you first loaded the dataset, it's positioned at first row (row 0).
Call mscript function $getData('dsID','fieldName') to retrieve a specific field at the current row of the dataset.
Call mscript function $nextDataSetRow('dsID') to advance move dataset to the next row.
Once the dataset is positioned at the desired index, you can call out each field on the current row using MScript function $getData (…), for example:
$getData ('myDS','F1') or $getData ('myDS:F1')
Just like other MScript functions, you may nest call like:
$getData ('$getData ('myDS:F1')_x','F22')
In the above example, the inner $getData ('myDS:F1') retrieves the value of column F1 from dataset myDS. The value returned is then concatenated with _x to form the dataset name for the outer $getData (…).
You may retrieve data using a short hand format [dsName:colName] just like calling out system and user variables:
Obviously your dataset name must not contain semi-colon “:” in order to use this short hand syntax.