Best way to return Enslib.Sql.GatewayResultset to BPL
Hi
I am fairly new to Ensemble development.
I was wondering what is the best process of returning the resultset from a SQL outbound adapter to the BPL that had invoked it.
Thank you for your help.
Kind Regards,
Salma
Comments
Hi
This is what my business operation looks like method looks like.
Method GetResultspRequest As GOSHPackage.Messages.PPID.Request.MyRequest, Output pResponse As GOSHPackage.Messages.PPID.Response.MyResponse) As %Status
{
Set tSC = $$$OK
Set pResponse = ##class(GOSHPackage.Messages.PPID.Response.MyResponse).%New()
Try
{
Set tSC = ..Adapter.Connect()
Throw:($$$ISERR(tSC))
Set tSC = ..Adapter.SetAutoCommit(1)
Throw:($$$ISERR(tSC))
$$$LOGINFO("2")
Set tQuery = "SELECT top 3 surname, forename FROM [dbo].[tblTest]"
//set tQuery =..Adapter.Query
$$$LOGINFO("3")
Set tSC = ..Adapter.ExecuteQuery(.tResults,tQuery,)
Throw:($$$ISERR(tSC))
set snap=##class(EnsLib.SQL.Snapshot).%New()
set tSC = tResults.GetSnapshot(.snap)
set pResponse.TestRS =snap
Throw:($$$ISERR(tSC))
$$$LOGINFO("5")
}
Catch tException
{
Set tSC = ##class(%SYSTEM.Status).Error(tException.AsStatus,tException.Name_" Threw an Error "_tException.DisplayString)
}
Quit tSC
}
This populates the snapshot however when I am trying to get the response back in to the BPL I get the following error
ERROR <Ens>ErrBPTerminated: Terminating BP PPID Shadow Processor # due to error: ERROR <Ens>ErrException: <INVALID OREF>zOnResponse1+2^GOSHPackage.Process.PPID.PPIDShadowProcess.Context.1 -- logged as '-' number - @' Set status=1,context.TestRS=callresponse.TestRS' > ERROR <Ens>ErrException: <INVALID OREF>zOnResponse1+2^GOSHPackage.Process.PPID.PPIDShadowProcess.Context.1 -- logged as '-' number - @' Set status=1,context.TestRS=callresponse.TestRS'
I am unsure whether this is the right approach, any help would be appreciated.
Thank you.
Salma
Hi
I have managed to resolve the issue using the following post
https://community.intersystems.com/post/using-snapshots-bpl
Kind Regards,
Salma
Congratulations,
that's engineering!
Hi,
Thank you for your comment are you able to provide me with an example? My assumption is that you are suggesting to define a class and create a list of objects which then get passed back to the BPL. At the moment I have a SQL resultset which I have assigned to a snapshot and returned it to the BPL.
Kind Regards,
Salma
Salma
My assumption is that you are suggesting to define a class and create a list of objects which then get passed back to the BPL
Yes, something like that. Or you can pass only id's of saved objects back. That makes ensemble messages lighter.
Snapshot is a very technical abstraction.
If possible, it's better to convert it to business object(s) and pass that.