I've writing a short classmethod that extracts an HL7 message from EnsLib.HL7.Message by ID and returns it as a stream. It's to be called as a stored procedure via ODBC (or ADO.NET) to fetch messages into an application. I'm not using an SQL query in the classmethod itself, but it will be called as part of an SQL query via ODBC, but I can't figure out how to set a custom SQLCODE and error text from within the classmethod that propagates back to the external application. I thought %sqlcontext would be useful for this, but it doesn't appear to do anything. Here's the class: Class User.HL7.Message Extends %RegisteredObject { ClassMethod Get(pId As %String) As %String [ SqlName = GetMsg, SqlProc ] { Set tMsg = ##class(%Stream.TmpCharacter).%New() Set tHl7 = ##class(EnsLib.HL7.Message).%OpenId(pId,,.tSC) If $$$ISERR(tSC) { Set %sqlcontext.%SQLCode = -400 Set %sqlcontext.%Message = "EnsLib.HL7.Message Object with ID "_pId_" Not Found - "_$System.Status.GetErrorText(tSC) QUIT "" } Do tHl7.OutputToLibraryStream(.tMsg) Return tMsg.Read(tMsg.Size) } } I've scoured the documentation, but I'm not getting it. Thanks in advance for any help!