1

I have to update a row in the table if Id is already presents, else insert a new row in the database using Spring Jdbc Template. I tried using MERGE query but since i am operating on a single table, I could not able to pass my insertion parameter values from outside(Merge insert params should come from DB) as shown below.

MERGE INTO TABLENAME INDS
USING (SELECT PRIMARY_ID SIC FROM TABLENAME  WHERE PRIMARY_ID = '223456789') E
ON (INDS.PRIMARY_ID=E.PRIMARY_ID) 
WHEN MATCHED THEN
UPDATE SET INDS.ROW_MOD_ID='ManualUpdate', ROW_MOD_TMST=sysdate
WHEN NOT MATCHED THEN
INSERT  (INDS.PRIMARY_ID, INDS.ROW_CRE_ID, ROW_CRE_TMST)
VALUES ('223456789', 'ManualInsert', sysdate);

I am using Oracle DB and worried about the performance. Is there any spring feature to address my problem? Any help is much appreciated.

Bhargav Kumar R
  • 2,190
  • 3
  • 22
  • 38

0 Answers0