conditionally update or insert using single query in Oracle table [closed]

别等时光非礼了梦想. 提交于 2020-03-05 04:27:30

问题


I am using jdbc to insert or update into a table based on the condition, if the data already exists in the table. I am getting data from an external source. Is it possible to have a single query to perform this task? scenario looks somewhat like this:

    if (if row with the data exists){
     perform UPDATE
    }else{
     perform INSERT
    }

回答1:


You can use

JSON_TABLE(JsonData,'$' , columns(column1    VARCHAR2(50 CHAR) PATH '$.column1'))

which will convert JSON data into relational view and then use the same in MERGE.

Refer this.



来源:https://stackoverflow.com/questions/60484178/conditionally-update-or-insert-using-single-query-in-oracle-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!