Correct usage of %Library.ListOfObjects containing EnsLib.SQL.Snapshot in Ensemble
I'm having trouble accessing the snapshots EnsLib.SQL.Snapshot in %Library.ListOfObjects that are returned from method ExecuteProcedure in EnsLib.SQL.OutboundAdapter. The Microsoft SQL stored procedure I am executing returns multiple resultsets.
The issue I am having is that my code works fine when executed in the business operation (commented out in the code below) but when it is executed in the business process it errors. Any ideas as to why this happens? The error I get is:
> ERROR #5002: Cache error: <METHOD DOES NOT EXIST>zGetAt+5 ^%Library.ListOfObjects.1 *%Open,%Library.RegisteredObject
The trace statements log the following in the business process:
Object: 11@%Library.ListOfObjects
Size: 2
Count: 2
Classes below:
ClassTest.Operations.SQLExtendsEns.BusinessOperation
ParameterADAPTER = "EnsLib.SQL.OutboundAdapter";
PropertyAdapterAsEnsLib.SQL.OutboundAdapter;
ParameterINVOCATION = "Queue";
MethodTesting(PREQUESTAsUHSM.Messages.Test, OutputPRESPONSEAs%Library.ListOfObjects) As%Status
{
Setquery="{call dbo.spTIE_Test(?)}"
Setsc= ..Adapter.ExecuteProcedure(.PRESPONSE,.outparams,query,"i",PREQUEST.RM2Number)
// The following works correctly when executed here
// While(PRESPONSE.GetNext(.x)) {
// Set snap = PRESPONSE.GetAt(x)
// While(snap.Next(.sc)) {
// $$$TRACE("Surname: "_snap.Get("Surname"))
// }
// }
Quitsc
}
XDataMessageMap
{
<MapItems>
<MapItemMessageType="UHSM.Messages.Test">
<Method>Testing</Method>
</MapItem>
</MapItems>
}
}
ClassUHSM.Processes.TestExtendsEns.BusinessProcess
{
MethodOnRequest(pRequestAsEns.Request, OutputpResponseAsEns.Response) As%Status
{
setsc=$$$OK
Setsc= ..Testing()
Quitsc
}
MethodTesting() As%Status
{
Setreq=##CLASS(UHSM.Messages.Test).%New()
Setreq.RM2Number="1212312"
Setsc=..SendRequestSync("Test SQL",req,.resultSet,20)
$$$TRACE("Count: "_resultSet.Count())
$$$TRACE("Size: "_resultSet.Size)
$$$TRACE("Object: "_resultSet)
$$$TRACE(sc)
While(resultSet.GetNext(.x)) {
Setsnap=resultSet.GetAt(x)
While(snap.Next(.sc)) {
$$$TRACE("Surname: "_snap.Get("Surname"))
}
}
Quitsc
}
}
Thanks,
Graham
Comments
Create a response wrapper and use it. %ListOfObjects is serial, not persistent.
Class MyResponse Extends %Persistent {
Property Snapshots As List Of EnsLib.SQL.Snapshot;
}Thanks Eduard, that's really helped. I have now got it to work.
Graham