Hi Dale,
That was great. I've actually two problems:-1) I want to write the Blob to an external Cache Namespace.
2) I want to write it to an MS sql table. preferrably through a Stored Procedure.
For 1, I use what you suggested..within SQL.OutboundAdapter using ODBC to the external CACHE namespace.
Set tWriter = ##class(%XML.Writer).%New()
Set tXMLStream = ##class(%Stream.GlobalBinary).%New()
Set tStatus = tWriter.OutputToStream(.tXMLStream)
If $$$ISERR(tStatus) Quit tStatus
Set tStatus = tWriter.RootObject(pRequest)
If $$$ISERR(tStatus) Quit tStatus
// Now we have the XML in the tXMLStream object
Do tXMLStream.Rewind()
//now write to cache table
Set sql="insert into "_..BOSTable_" (MessageID ,Trader , MessageType, MessageData, MessageTaken, MessageConfirmed, Binary, Zipped, ReadDataFromDisk, TakenCount, InsertDate) values (?,?,?,?,?,?,?,?,?,?,?)"
Set sc=..Adapter.ExecuteUpdate (.rowsAffected,sql,
pRequest.BossPatient.MailerTypeID_"."_pRequest.Transmission.TransmissionReference
,pRequest.Transmission.ReceiversId
,"BOSS"
,tXMLStream
,0,0,0,0,0,0
,$ZDate($piece($horolog,",",1),3) _ " " _ $ZTime($piece($horolog,",",2),1)
)
and it seems to work. I get rows added and the Blob appears to have my XML data.
When i try the exact same code (i.e. not using the Stored Procedure), but using ODBC to an MS sql database.
I get an error...
ERROR #6022: Gateway failed: BindParameters. + ERROR <Ens>ErrGeneral: SQLState: (HY104) NativeError: [0] Message: [Microsoft][ODBC SQL Server Driver]Invalid precision value
Investigating it is the MessageData Field that is causing the problem.
Where "MessageData" is defined in the SQL database table as "Image"
Any thoughts..
Thanks
Mike