set MyQuery="SELECT * FROM Myclass"
set ResultSet=##class(%ResultSet).%New("%DynamicQuery:SQL")
set status=ResultSet.Prepare(MyQuery)
set status=ResultSet.Execute()
While ResultSet.Next() {
set Id=ResultSet.Data("ID")
Set oref=##class(MyClass).%OpenId(Id)
----then do what I need to do ------
}
D $system.OBJ.Dump(ResultSet)
+----------------- general information ---------------
| oref value: 2
| class name: %Library.ResultSet
| OID: ""
| reference count: 2 (system)
+----------------- attribute values ------------------
| %Message = ""
| %Metadata = ""
| (%NextColumn) = ""
| %Objects = (("ID","tiu.ClinicalDocumentEvent","%QuickLoad^tiu.ClinicalDocumentEvent.T1(%rowid,%nolock,0,0)"))
| %Parameters = ""
| %PrivateTables =
| %RowCount = ""
| (%RuntimeMode) = ""
| %SQLCode = ""
| (%rsmd) = ""
| (AtEnd) = 0
| ClassName = "%Library.DynamicQuery"
| (ColExtInfo) = ""
| (ColIndex) = 7
| (ColIndex(1)) = ID
| (ColIndex(2)) = documentContent
| (ColIndex(3)) = documentId
| (ColIndex(4)) = documentSubject
| (ColIndex(5)) = documentTitle
| (ColIndex(6)) = patientId
| (ColIndex(7)) = siteId
| (ColInfo) = (("ID",10,"ID"),("documentContent",10,"documentContent"),("documentId",10,"documentId"),("documentSubject",10,"documentSubject"),("documentTitle",10,"documentTitle"),("patientId",10,"patientId"),("siteId",10,"siteId"))
| (HasExtInfo) = 0
| (HasInfo) = 1
| (IdInfo) = (1,"tiu.ClinicalDocumentEvent")
| (IsOpened) = 1
| (NextColumn) = 0
| (ParamInfo) = ""
CacheSql239(QHandle) = X
| QueryName = "SQL"
| RuntimeMode = ""
| (StatementType) = ""
+----------------- swizzled references ---------------
+-----------------------------------------------------