%ResultSet.SQL
Class %ResultSet.SQL Extends (%Library.IResultSet, %ResultSet.QuerySuper) [ System = 4 ]
This class has been superseded. It will remain for compatibility with existing code and samples. We recommend using %SQL.Statement.
Cached ResultSet based on an SQL statement. This class only supports the SELECT statement.
Methods
%Prepare
ClassMethod %Prepare(ByRef sqlStatement As %String(MAXLEN=""), ByRef returnError As %SYSTEM.Error, %importPackages As %RawString = "", %args...) As %ResultSet.SQL [ PublicList = (SQLCODE, resultSet, returnStatus) ]
%Prepare() This method is different for each type of result set class. This method has two tasks. First, instantiate the correct concrete result set class. For %ResultSet.SQL that means accepting the sql query text in the first parameter and looking up the query implementation in the query cache. The second task is to prepare the resulting object for data retrieval by the caller which is done in %OnNew. The assumption is that if the query requires any parameters then the actual arguments are all literal or public variables.
For %ResultSet.SQL, the arguments are:
sqlStatement (byref)
the SQL Select statement, either as a counted array or as a $$$NL delimited string;
returnError (byref)
if an error occurs, this will be an oref of an instance of %SYSTEM.Error. That object has a Status property as well as methods to convert that status value into message id's and text from other error domains. If no error is detected during %Prepare then returnError is $$$NULLOREF;
%importPackages
this is a $list of package names to be used to resolve any unqualified names in the SELECT statement.
For example, SELECT %ID from MyTable
If %importPackages contains "Sample" then the schema associated with the Sample package would be used to qualify MyTable.
%args...
variable number of argument values that correspond to '?' parameters contained in the sqlStatement.
This method returns an instance of %Library.IResultSet in the generic case. In the case of %ResultSet.SQL, an instance of %ResultSet.SQL is returned.
This method constructs a SaveSet containing objects that are part of the current %Save() for persistent classes or %GetSwizzleObject for serial classes. A queue of objects to be saved or serialized is also constructed. Only modified objects are included in the save queue. The value (OID or serial value in OID form) of each object is also placed in the SaveSet.
%PrepareMetaData
ClassMethod %PrepareMetaData(ByRef txtSQL As %String(MAXLEN=""), ByRef returnError As %SYSTEM.Error = "", importPackages As %RawString = "") As %ResultSet.MetaData
%PrepareMetaData is similar to %Prepare except that no result set is instantiated. This method returns a %ResultSet.MetaData object. Be aware that the implementation of this method might cause the result set to be instantiated but that is up to the result set class itself and no result set is actually returned by this method - only metadata.
query | This is the SQL SELECT statement |
---|---|
returnError | If an error occurs this is returned by reference and is a %SYSTEM.Error object with properties set to describe information about the error. %returnError.Status contains the %Status value. |
importPackages | This is a comma delimited list of packages to import. This is only relevant if the result set implementation is generated and the query source might include unqualified names. The import packages list is used to resolve package/schema names for unqualified names. |
%NormalizeObject
Method %NormalizeObject() As %Status [ CodeMode = expression ]
%ValidateObject
Method %ValidateObject(force As %Integer = 0) As %Status [ CodeMode = expression ]
%SerializeObject
Method %SerializeObject(ByRef serial As %Binary, partial As %Integer = 0) As %Status [ CodeMode = expression ]
%ConstructClone
Method %ConstructClone(deep As %Boolean = 0, ByRef cloned As %String, location As %String) As %RegisteredObject [ CodeMode = expression, ProcedureBlock = 1, ServerOnly = 1 ]
%AddToSaveSet
Method %AddToSaveSet(depth As %Integer = 3, refresh As %Integer = 0, norecurseon As %String = "") As %Status [ CodeMode = expression, Internal, ProcedureBlock = 1, ServerOnly = 1 ]
%RemoveFromSaveSet
Method %RemoveFromSaveSet() As %Status [ CodeMode = expression, Internal, ProcedureBlock = 1, ServerOnly = 1 ]