...you can pass ..Adapter.ExecuteQuery() a snapshot object (EnsLib.SQL.Snapshot) which will then get populated rather than a getting a result set returned. With this populated snapshot object, you can then iterate through it using its Next() method just like the result set, but then you can use its Rewind() method.
For example:
SetSnapshot = ##Class(EnsLib.SQL.Snapshot).%New()
Setsql = "SELECT * FROM MY_TABLE WHERE X= '"_Y_"'"Setstatus = ..Adapter.ExecuteQuery(Snapshot, sql)
While Snapshot.Next(){
//First run throughofsnapshot
}
Do Snapshot.Rewind()
While Snapshot.Next(){
//Second run throughofsnapshot
}
You can use %Library.ScrollableResultSet or Execute the query again.
Hey Yuri.
Depending on the context, this answer I gave for a similar question may be relevant:
...you can pass ..Adapter.ExecuteQuery() a snapshot object (EnsLib.SQL.Snapshot) which will then get populated rather than a getting a result set returned. With this populated snapshot object, you can then iterate through it using its Next() method just like the result set, but then you can use its Rewind() method.
For example:
Set Snapshot = ##Class(EnsLib.SQL.Snapshot).%New() Set sql = "SELECT * FROM MY_TABLE WHERE X= '"_Y_"'" Set status = ..Adapter.ExecuteQuery(Snapshot, sql) While Snapshot.Next(){ //First run through of snapshot } Do Snapshot.Rewind() While Snapshot.Next(){ //Second run through of snapshot }
Execute it again.