Question Thembelani Mlalazi · Mar 12, 2018

how to use SQL InBound Adapter

I have a service that that I would like to use to  poll the database table in MySQL server 2012 and get an id to use if the condition is met but have trouble achieving this here is what I have so far any suggestions please.

Method OnProcessInput(pInput As EnsLib.SQL.Snapshot, Output pOutput As %RegisteredObject) As %Status
{
 
  set pRequest=##class(SamsReq).%New()
      set pRequest.pID=pInput.Get("pID")
     
     
 

< set sc=..SendRequestSync("DQTT",pRequest,.pOutput)

 quit sc
}
 
 

the error that I am getting

>}

ERROR <Ens>ErrBPTerminated: Terminating BP DQTT # due to error: ERROR <Ens>ErrException: <COMMAND>zMessageHeaderHandler+18 ^Ens.BusinessProcess.1 -- logged as '-'
number - @'
Set tSC=..OnRequest(..%request,.tResponse)'
 
 

Comments

Scott Roth · Mar 12, 2018

I have used this in the past...

Under my Data Settings I use the following as my Query to act like a status kick off for my job...

SELECT  1

Then my service does...

Method OnProcessInput(pInput As EnsLib.SQL.Snapshot, pOutput As %RegisteredObject) As %Status
{
     set req=##class(osuwmc.CPD.DataStructures.StartJobRequest).%New()
     set req.StartJobStatus = pInput.Get("1")
     set sc = ..SendRequestSync("CPDClarityAddressUpdateBPL",req,.pOutput)
    Quit sc
}

It appears you are not setting your request variable so there is nothing to send to your DQTT.

0
Thembelani Mlalazi  Mar 12, 2018 to Scott Roth

@Scott Roth  have tried your suggestion still same problem .Under Data Settings I have a query "SELECT ID FROM dbs.DBS WHERE Status='Pending'" and the above code just in case I did not do it right please advise

0
Scott Roth  Mar 12, 2018 to Thembelani Mlalazi

What does your... ##class(SamsReq).%New() look like? Here is what my Request and code look like as a whole. I have used this many times across many services in different fashions. I am using JDBC vs ODBC which maybe a difference, not sure.


Class osuwmc.CPD.DataStructures.StartJobRequest Extends (%Library.Persistent, %XML.Adaptor) [ Not ProcedureBlock, SqlRowIdPrivate ]
{
Property StartJobStatus As %Integer;
Storage Default
{
<Data name="StartJobRequestDefaultData">
<Value name="1">
<Value>%%CLASSNAME</Value>
</Value>
<Value name="2">
<Value>StartJobStatus</Value>
</Value>
</Data>
<DataLocation>^osuwmc.CPD59D.StartJobReqE986D</DataLocation>
<DefaultData>StartJobRequestDefaultData</DefaultData>
<IdLocation>^osuwmc.CPD59D.StartJobReqE986D</IdLocation>
<IndexLocation>^osuwmc.CPD59D.StartJobReqE986I</IndexLocation>
<StreamLocation>^osuwmc.CPD59D.StartJobReqE986S</StreamLocation>
<Type>%Library.CacheStorage</Type>
}
}


Class osuwmc.CPD.UpdateClarityAddressesFromCPDService Extends Ens.BusinessService [ ClassType = "", ProcedureBlock ]
{
Parameter ADAPTER = "EnsLib.SQL.InboundAdapter";
Parameter REQUESTCLASSES As %String = "EnsLib.SQL.Snapshot";
Property InitDSN As %String;
Method OnInit() As %Status
{
Set ..InitDSN = ..Adapter.DSN
//Set ..Adapter.ConnectAttrs = "QueryTimeout:45" ; try this too just in case...
Quit $$$OK
}
Method OnProcessInput(pInput As EnsLib.SQL.Snapshot, pOutput As %RegisteredObject) As %Status
{
set req=##class(osuwmc.CPD.DataStructures.StartJobRequest).%New()
set req.StartJobStatus = pInput.Get("1")
set sc = ..SendRequestSync("CPDClarityAddressUpdateBPL",req,.pOutput)
    Quit sc
}
}
 

0
Eduard Lebedyuk · Mar 12, 2018

Are you sure the problem is with the BS? Does visual trace stops there?

Is your target BP compiled?

0