ResultSetSample()
// Build query string
Set sql = "Select Value, DateTimeStamp From Spectrum_Support_Metrics.EnsPerformanceMetricsData Where " _
"CheckType = 'datasize' AND " _
"Detail = '/ensemble/mgr/PROD/' AND " _
"DateTimeStamp > '201012170930'"
// Create new resultSet object to work with called "rs". It's basically a cursor.
// This %Prepare command executes the query contained in "sql", sets the result to "rs", and gives an "error" flag back.
Set rs = ##class(%ResultSet.SQL).%Prepare(sql,.error,"")
// Check to see that the query executed without error.
If $IsObject(error) {
// In here is where you do something if you get an error.
Write "Error = " _ error
Quit 0
}
// Lets use a While statement to loop over each row returned from the query.
// The %Next command on the result set loads in the first row, and parses over the rest.
While (rs.%Next()) {
// Use the %Get command to get the value of the column specified, in this case, "Value".
Write "Value = " _ rs.%Get("Value") _ " at " _ rs.%Get("DateTimeStamp") _ " date/time.", !
}