| Argument | Description | Types / Required |
| dataId | The resource ID returned by Data.open, or a dictionary name. | number, string
recommended |
The data source is identified using
dataId. If specified as a string, it references the data source that is connected to a dictionary that is part of an application. If specified as a number, it is processed as a
resource ID returned by
Data.open. This typically references non-application data sources. While optional, this should generally be specified explicitly. (If there is only one data source open, the resource ID can be calculated implicitly.)
If the data source previously opened was a dictionary that is part of an application, this action does not actually close the data source, as it is "owned" by the application, but instead ends the Action Invoker's ability to access this data source using dataId.
For data sources not connected to application dictionaries, the data source is closed and additional actions or queries cannot occur until opening the data source again.
This action is similar to the CSPro
logic function
close.
The action returns undefined.
The action throws an exception if any of its arguments are not specified in a valid form, or if:
- The data source ID is not valid.
- There is an error closing the data source.
Even if there is an error closing the data source and an exception is thrown, the data source ID is no longer valid following this action.
let dataId;
try {
// open the Popstan Census example data
dataId = CS.Data.open({
connection: "Popstan Census.csdb"
});
// display the number of cases
const numCases = CS.Data.countCases({
dataId: dataId
});
print(`Popstan Census contains ${numCases} cases.`);
}
catch (error) {
print("Error interacting with data source: " + error);
}
finally {
// close the data source
if( dataId != undefined ) {
CS.Data.close({
dataId: dataId
});
}
}