InterSystems Reports - Logi Report (23.2) - How to code a stored procedure that will return a result set to be used in a report
A report that I need to create - I need to write a class method that will execute a few queries and save the data to a class and then return the data in a result set that can be used in the Logi report as a Stored procedure.
I can create the class method that is a Stored procedure and do the queries and manipulate the data, however I am having an issue at the end of the method to return the fields back as a result set.
I have looked at the Intersystems' documentation for the stored procedures but not finding a good example for a class method that is a stored procedure which returns a result set (multiple rows and 8 columns)
If you have any examples or suggestions please let me know.
Thanks.
Hello Kris, one of possible approaches might be using a custom query - see Custom Class Queries | InterSystems IRIS Data Platform 2024.1
Dan
Have a look to this post:
https://community.intersystems.com/post/call-stored-procedure-select-ins...
I have many integrations using JDBC stored procedure calls against MS SQL.
Class osuwmc.CPD.DataStructures.CheckProviderSpecialty Extends (%Library.Persistent, %XML.Adaptor) [ Not ProcedureBlock, SqlRowIdPrivate ] { Property DoctorNumber As %String(MAXLEN = 6); Storage Default { <Data name="CheckProviderSpecialtyDefaultData"> <Value name="1"> <Value>%%CLASSNAME</Value> </Value> <Value name="2"> <Value>DoctorNumber</Value> </Value> </Data> <DataLocation>^osuwmc.CPD59D.CheckProvideAF3D</DataLocation> <DefaultData>CheckProviderSpecialtyDefaultData</DefaultData> <IdLocation>^osuwmc.CPD59D.CheckProvideAF3D</IdLocation> <IndexLocation>^osuwmc.CPD59D.CheckProvideAF3I</IndexLocation> <StreamLocation>^osuwmc.CPD59D.CheckProvideAF3S</StreamLocation> <Type>%Storage.Persistent</Type> }
Include (EnsSQLTypes, %occODBC) Class osuwmc.Epic.MFN.EpicMFNToCPDDBWriteDEV Extends Ens.BusinessOperation [ ClassType = "", ProcedureBlock ] { Parameter ADAPTER = "EnsLib.SQL.OutboundAdapter"; Parameter INVOCATION = "Queue"; Property InitDSN As %String; Method OnInit() As %Status { Set ..InitDSN = ..Adapter.DSN Kill $$$EnsRuntimeAppData(..%ConfigName) //Set ..Adapter.ConnectAttrs = "QueryTimeout:45" ; try this too just in case... Quit $$$OK }
Method CheckDoesProviderExists(pRequest As osuwmc.CPD.DataStructures.CheckDoesDoctorNumberExist, Output pResponse As EnsLib.SQL.Snapshot) As %Status { set SPQuery = "{ ?= call InterfaceCheckDoctorNumber(?) }" set parm = 2 set parm(1,"SqlType")=$$$SQLVARCHAR set parm(1,"IOTypes")=$$$SQLPARAMOUTPUT set parm(2)=pRequest.DoctorNumber set parm(2,"SqlType")=$$$SQLVARCHAR set parm(2,"IOTypes")=$$$SQLPARAMINPUT set tSC = ..Adapter.ExecuteProcedureParmArray(.CheckDoctor,.outputs,SPQuery,"oi",.parm) if tSC = 1 { set pResponse = CheckDoctor.GetAt(1) } quit tSC }
Let me know if you need additional help, but this should give you a good start.