Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

PutSQL PG with MERGE go in success but it doesn't apply the changes in the DB

avatar
New Contributor

I'm trying to create a PG in NIFI that implements the following MERGE as a query:

 

 

MERGE INTO MCPR_OWN.LIVENESS l
     USING (select ? as cdn from dual) ct 
     ON (ct.cdn = l.cdn)
  WHEN MATCHED THEN 
    UPDATE SET 
      l.LIVENESS_ENABLE  = ?, 
      l.DATETIME_LIVENESS_UPDATE  = TO_DATE(?,'YYYY-MM-DD HH24:MI:SS')
    WHERE (l.DATETIME_LIVENESS_UPDATE < TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'))
  WHEN NOT MATCHED THEN 
    INSERT (CDN, LIVENESS_ENABLE, DATETIME_LIVENESS_UPDATE) 
    VALUES (?, ?, TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'))

 

 

Mapping the parameters in a PG of type UpdateAttribute set as shown in the figure:

 

cmgb9.pngjkqy1.png

 

While as far as the PutSQL PG settings are concerned, they are as follows:

 

Ue40y.png

 

The problem is that even if the PG containing the MERGE returns a success, the modifications do not affect the DB on which NIFI points. Can anyone give me some more information ?

 

We also carry out tests by connecting directly to the DB via DBeaver and the query works fine. The query tested on DBeaver follows:

 

 

MERGE INTO LIVENESS l
     USING (select :cdn as cdn from dual) ct 
     ON (ct.cdn = l.cdn)
  WHEN MATCHED THEN 
    UPDATE SET 
      l.LIVENESS_ENABLE  = :liv_en, 
      l.DATETIME_LIVENESS_UPDATE  = TO_DATE(:dtp,'YYYY-MM-DD HH24:MI:SS')
    WHERE (l.DATETIME_LIVENESS_UPDATE < TO_DATE(:dtp,'YYYY-MM-DD HH24:MI:SS'))
  WHEN NOT MATCHED THEN 
    INSERT (CDN, LIVENESS_ENABLE, DATETIME_LIVENESS_UPDATE) 
    VALUES (:cdn, :liv_en, TO_DATE(:dtp,'YYYY-MM-DD HH24:MI:SS'));

 

 

Unfortunately I don't have access to NIFI logs.



1 REPLY 1

avatar

Hi,

I noticed you are using "$(cdn)" instead of "${cdn}" for sql.args1.value to probably reference the flow file attribute cdn which you are using as merge key. That is probably why the merge has no effect because its looking for the string "$(cdn)" instead of the attribute value "${cdn}".