SQL Outbound Adapter - Return SQLCODE

69 views
Skip to first unread message

John

unread,
Jun 27, 2013, 10:09:30 AM6/27/13
to Ensemble-in...@googlegroups.com
Hello,
I have a SQL adapter which executes Stored Procedures against a SQL database.  However I need it to return the SQL return code, which I want to use to determine whether the SP call has been successful or not?  Is there a way to get the SQLCode back?  I thought there was some kind of %SQLCODE property I could get back?  Something like  set pResponse.ResultCode = ..Adapter.%Connection.%SQLCODE?
 
 Class pacPICTSLib.SQL.opeSQL Extends Ens.BusinessOperation [ ProcedureBlock ]
{

Parameter ADAPTER = "EnsLib.SQL.OutboundAdapter";

Parameter INVOCATION = "Queue";

Method OnMessage(pRequest As reqSQL, Output pResponse As resSQL) As %Status
{
set pResponse = ##Class(pacMARTS.resSQLMessage).%New()
set pResponse.SQLRequest = pRequest

//Now execute the  SQL
Set tSC = ..Adapter.ExecuteUpdate(.intRowAffected,pRequest.SQLScript)
set pResponse.RowsAffected = intRowAffected
set pResponse.Result = tSC
if $$$ISERR(tSC) {
set ..Retry=1
$$$LOGERROR("Error: "_tSC)
else {
$$$TRACE("All OK")
}

Quit tSC
}

XData MessageMap
{
<MapItems>
<MapItem MessageType="pacPICTSLib.SQL.reqSQL">
<Method>OnMessage</Method>
</MapItem>
</MapItems>
}

}

Ted Peck

unread,
Jun 27, 2013, 10:34:07 AM6/27/13
to Ensemble-in...@googlegroups.com, John
It is called ..Adapter.%Connection.sqlcode
however I'm not sure it's good for much in the case of JDBC DSNs. Also the Adapter generally makes several xDBC calls and I'm not sure whether later ones to retrieve the error status might overwrite the sqlcode you care about from the main xDBC call.
Also you should be aware that Ensemble will log the error and set the Retry flag in most cases. What you're doing is OK but probably redundant.

Ted
--
You received this message because you are subscribed to the Google Groups "InterSystems: Ensemble in Healthcare Community" group.
To post to this group, send email to Ensemble-in...@googlegroups.com
To unsubscribe from this group, send email to Ensemble-in-Healt...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Ensemble-in-Healthcare?hl=en
---
You received this message because you are subscribed to the Google Groups "InterSystems: Ensemble in Healthcare" group.
To unsubscribe from this group and stop receiving emails from it, send an email to Ensemble-in-Healt...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages