How do I get a specific Row values from the dataset
This example demonstrates fetching the number of rows in a dataset after reading the data from a data file.
In the solution shown below, a dataset is created using "ddCreateDataSet" command. The data from the data file is read into this dataset using "ddCreateDatasetFromADatafile" command. The values of a specific row is fetched from the dataset using "ddGetRowValues" command and stored into another dataset. The new 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 dataset | |||
2 | ddCreateDatasetFromADatafile | Insurance Details(W) | InsuranceDetails |
Getting the values of a specific row from the dataset and storing it in another dataset | |||
3 | ddGetRowValues |
InsuranceDetails(1) | InsuranceDetailsSingleRow |
Persisting the dataset consisting of the required row values to a data file | |||
4 | ddPersistDatasetToDataFile |
InsuranceDetailsSingleRow | Insurance Details Single Row(W) |
Tips, Tricks, Gotcha's & Best Practices:
- You should use the same dataset name which is created by using "ddCreateDataSet" command in "ddCreateDatasetFromADatafile" and "ddGetRowValues" commands.
- 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.
- As a best practice, it is always advisable to define the variable names without any spaces and if you want to differentiate the words, use underscores.