Abstract version of the resultset which specific implementations of result sets inherit from.
A result set is a type of result returned by executing either a SELECT statement or a CALL statement.
Please refer to %SQL.Statement and %SQL.StatementResult for more
information on how to prepare dynamic SQL statements and how to process the results the
of executing them.
Used to store the data returned from the resultset by column name. This can
be accessed directly for more performance than the Get() and
GetDataByName() as it avoids a method call. For example code
that said:
While result.Next() {
Write result.Get("Name"),result.Get("Salary"),!
}
; Becomes this faster code
While result.Next() {
Write $get(result.Data("Name")),$get(result.Data("Salary")),!
}
Note that as this 'Data' property is multidimensional if there
is no such column name as 'Salary' you will get an UNDEFINED error without
the $get around it. If
there are two columns with the same name in the result set then the second
one will be the one referenced by the 'Data' property. If you need to refer
to both of them use the GetData() and give the position
of the column you want.
Use this method to set the SQL runtime mode for the query to be
executed. Setting the runtime mode for this ResultSet does not
permanently change the $zu(115,5) value. Possible values mode are:
If the current query contains an object Id (based on the CONTAINSID parameter
being set), return the column position of the object Id.
Otherwise return 0.
Returns the value of the column with the name name in the current row of the result set.
If name is not a valid column name, this method returns an empty string.
Look at updating the code to use the Data multidimensional property to
access the fields faster than using this method call.
The name of the extent that this query will return Id values from (based on the EXTENT parameter
being set). Only returns a value if the query contains Id values.
Use this method with dynamic queries to provide the query to be
executed. In the case of the %DynamicQuery:SQL query, p1
is a string containing an SQL query. The query may contain parameters represented
by ? characters within the query. The values of any parameters are
supplied via the Execute() method. For example:
Set result=##class(%ResultSet).%New("%DynamicQuery:SQL")
Do result.Prepare("SELECT Name,City FROM Person WHERE Name %STARTSWITH ? AND City = ?")
Do result.Execute("A","Boston")
While result.Next() {
Write result.Data("Name"),result.Data("City"),!
}