How do I assign values to a row in a dataset
This example demonstrates assigning values of a specific row from one dataset to another dataset.
In the solution shown below, two datasets are created using "ddCreateDataSet" command. The data from the data file is read into first dataset using "ddCreateDatasetFromADatafile" command. A row is added to the second dataset using "ddAddRows" command. The values of a specific row(third row) is copied from first dataset to second dataset using "ddSetRowValues" command. The second dataset consisting of the required row values is persisted to the data file using "ddPersistDatasetToDataFile" command.
Solution:
# | Command | Target | Value |
---|---|---|---|
Creating the dataset and specifying the data definition name of the data file | |||
1 | ddCreateDataSet | InsuranceDetails |
Insurance Details(W) |
Reading the data from the data file into the first dataset | |||
2 | ddCreateDatasetFromADatafile | Insurance Details(W) | InsuranceDetails |
Creating the second dataset and specifying the data definition name of the data file | |||
3 | ddCreateDataSet |
InsuranceDetailsSingleRow | Insurance Details(W) |
Adding a row to the second dataset | |||
4 | ddAddRows |
InsuranceDetailsSingleRow | 1 |
Setting the values of a specific row from first dataset to second dataset | |||
5 | ddSetRowValues |
InsuranceDetails(2) | InsuranceDetailsSingleRow(0) |
Persisting the second dataset consisting of the required row values to a data file | |||
6 | ddPersistDatasetToDataFile |
InsuranceDetailsSingleRow | Insurance Details Single Row(W) |
Tips, Tricks, Gotcha's & Best Practices:
- You can also pass the data filter name along with the data file name using the separator "||" in "ddCreateDatasetFromADatafile" command to read only the filtered rows into the dataset from the data file. To know more about data filters click here.
- You can optionally pass the status of the Data Definition and Data file along with their names in "ddCreateDataSet", "ddCreateDatasetFromADatafile" and "ddPersistDatasetToDataFile" commands. Allowed values for status are 'W'(WIP) and 'A'(Active). If the status value is not passed, the status is assumed to be 'W'(WIP) for "ddCreateDataSet" and "ddCreateDatasetFromADatafile" commands and 'A'(Active) for "ddPersistDatasetToDataFile" command.