· Mar 23, 2023

Saving data into SQL table

Hi Community,

I am trying to save data into SQL table but each entry  getting saved twice in the SQL table. Is there any reason data is saving Twice in the SQL table 

I have created a %Persistent class for the fields

Please find the business operation below


Class Patient.DBOperation Extends Ens.BusinessOperation


Parameter ADAPTER = "EnsLib.SQL.OutboundAdapter";

Property Adapter As EnsLib.SQL.OutboundAdapter;

Parameter INVOCATION = "Queue";

Method OnMessage(pInput As Patient.PatientDBReq, pOutput As Ens.Response) As %Status
    Set Entry=##class(Patient.PatientDBReq).%New()
    Set Entry.PatientID=pInput.PatientID
    Set Entry.AdmDateandTime=pInput.AdmDateandTime
    Set sc=Entry.%Save()
    $$$LOGINFO("Onmessage "_"`"_sc)
    Quit sc


Patient.PatientDBReq Class

Class Patient.PatientDBReq Extends Ens.Request

Property PatientID As %Numeric;

Property AdmDateandTime As %DateTime;





Product version: Ensemble 2018.1
$ZV: Cache for Windows (x86-64) 2018.1.1 (Build 312_1_18937U) Fri Apr 26 2019 17:58:36 EDT
Discussion (6)1
Log in or sign up to continue

Hi Oliver Wilms 

I have used   Ens.Request Extension class for Patient.PatientDBReq , the Ens.Request class is like below 

Class Ens.Request Extends (Ens.MessageBody, Ens.Util.RequestBodyMethods) -->Can you please tell how it will be saved without calling %Save()?

So if i use  %Persistent  Extension class for Patient.PatientDBReq  class do i need to call %Save() for saving data into SQL table?