Returning a Stream in an ObjectScript Custom SQL Function
I'm attempting to extract some very large messages from Interoperability/Ensemble, and I'm just not getting something right ...
The closest I've come to getting something useful is this:
ClassMethod GetHL7Msg(pId As %String) As %Stream.TmpCharacter [ SqlName = GetMsg, SqlProc ]
{
Set tHl7 = ##class(EnsLib.HL7.Message).%OpenId(pId,,.tSC)
Throw:$$$ISERR(tSC) ..GetErr(-400, "HL7 Message with ID "_pId_" Not Found.")
Set tMsg = ##class(%Stream.TmpCharacter).%New()
Set tSC = tHl7.OutputToLibraryStream(.tMsg)
Do tHl7.%Close()
Return tMsg
}
When I call this via an ODBC query:
SELECT ID, SourceConfigName, TargetConfigName, HICG.GetMsg(MessageBodyId) As Message FROM Ens.MessageHeader
WHERE
MessageBodyClassName = 'EnsLib.HL7.Message' AND
TargetConfigName = 'OptumMdmOut'
ORDER BY ID ASC
I get a single, properly formed row back (there should be 1,000), and an error in the xDBC Errors log in IRIS:
Any thoughts?