%Library.IResultSet
abstract class %Library.IResultSet extends %Library.RegisteredObject
Interface for result sets.
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.
Property Inventory
Method Inventory
- %CreateSnapshot()
- %DispatchGetProperty()
- %DispatchMethod()
- %Display()
- %DisplayFormatted()
- %Get()
- %GetData()
- %GetMetadata()
- %Next()
- %Prepare()
- %PrepareMetaData()
- %Print()
- %ResultColumnCountGet()
- %SendDelimitedRows()
Parameters
Properties
Methods
Display the contents of the result object. If formatted display is available then format the results using the requested format and, if appropriate, open the formatted results using the host OS. The output is directed to one or more files and messages are placed in a result set object. All file names used are returned in an array.
Parameters
Name | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
pFormat |
The format applied to the result content. This parameter is also used to determine the file name extension. Supported formats are:
If pFormat is specified as any number not listed above then it will default to TXT. pFormat can also be specified as XML, HTML, PDF, TXT or CSV. NOTE: pFormat of CSV/100 is not a true comma separated value, but instead uses TAB separated values. |
||||||||||||
pFileName |
The base file name to be used to generate actual file names used for output. If no value is specified then a file name will be generated, using the TEMP folder defined for the InterSystems IRIS instance. This value is not expected to include an extension. An extension is added to this value to form the actual file used. Also, if nested results exist then a number is appended to the file name specified to produce a unique name for each result. |
||||||||||||
pMessages |
Instance of a system result set class. If no value is passed then the system message result class is instantiated. This parameter is passed by reference. It is up to the caller to process the result set oref that is returned. pMessages.Count() returns the number of messages contained in the result set. pMessages.%Display() will display the messages on the current device. pMessages.%DisplayFormatted() is also implemented and can be used to display the messages using the selected format. |
||||||||||||
pFilesUsed |
This pass-by-reference parameter will contain the number of files used to display the result content and the name of each file. pFilesUsed is the number of files and pFilesUsed(file_number) is the name of the file. The sequence of the files is the same sequence as the results are processed. For simple result objects, there is a single file. For context objects that can contain result set sequences, the results are output in the order they are returned and the files used are present in pFilesUsed in that same order. |
||||||||||||
pTranslateTable |
This is the translate table used for the output files when the format is CSV or TXT. This parameter is optional. |
||||||||||||
pDelimiter |
The delimiter to use between columns in the export file. This parameter is optional and defaults to tab character if not specified. |
If name is not a valid column name, this method returns an empty string.
This method is different for each type of result set class. This method has two tasks. First, instantiate the correct concrete result set class. Think of the first parameter, queryId, as being an "index key value" that is used to lookup the correct query implementation. For non-cached (static) queries this is simply the name of the class that implements the query, i.e. the %IResultSet interface. The second task is to prepare the resulting object for data retrieval by the caller.
- This can be the concrete subclass of %IResultSet that implements the desired query. For dynamic cached results this value
is generally the query text that can be parsed, a hashed value computed and the cached result implementation class
looked up in the query cache index.
queryId can also be a <className><colon><queryName> or <className><colon><methodName>. If it is a <queryName> then the result set returned is an instance of %Library.ResultSet that is bound to that query. If it is the name of a method Then that method is called, passing %args... to the method, and the first result set found in the context object (%sqlcontext) is returned.
- 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.
- Argument values to be passed to the query/method/class %Execute()() method. Zero, one or more argument values can be passed.
- This can be the concrete subclass of %IResultSet that implements the desired query. For dynamic cached results this value
is generally the query text that can be parsed, a hashed value computed and the cached result implementation class
looked up in the query cache index.
queryId can also be a <className><colon><queryName> or <className><colon><methodName>. If it is a <queryName> then the metadata is retrieved from the compiled query. If it is the name of a method then no metadata can be prepared since it requires the method to be executed.
- 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.
Write the current row to the current device. An optional column delimiter can be specified. No formatting is applied other than writing pDelimiter between column values. This can be useful for exporting result set data to tab delimited files.
For example:
set sql = "select name,home_street,home_city,home_state,home_zip from sample.person" set rset = ##class(%ResultSet.SQL).%Prepare(.sql,.err,"") if '$Isobject(err) { set file="c:\temp\names.asv" open file:"WNS" use file while rset.%Next() { do rset.%Print($char(9)) } close file }
Example data:
Cornell,Ezra M. | 340 Franklin Court | Sarasota | NY | 12866 |
Huff,Stephen A. | 548 Washington Blvd | Brownfield Center | MD | 53436 |
Sands,Jeep Q. | 7298 Washington Drive | Xavier | WY | 23685 |
Inherited Members
Inherited Methods
- %AddToSaveSet()
- %ClassIsLatestVersion()
- %ClassName()
- %ConstructClone()
- %DispatchClassMethod()
- %DispatchGetModified()
- %DispatchSetModified()
- %DispatchSetMultidimProperty()
- %Extends()
- %GetParameter()
- %IsA()
- %IsModified()
- %New()
- %NormalizeObject()
- %ObjectModified()
- %OriginalNamespace()
- %PackageName()
- %RemoveFromSaveSet()
- %SerializeObject()
- %SetModified()
- %ValidateObject()