Oracle merge statement merge into table name a using (select? As field 1 ,? As field 2 ,..... from dual) B on (. field 1 = B. field 1 and ....) (Judgment condition) when matched then update set field 1 = Field 1 ,...... when not matched then insert (Field 1, Field 2 ,...) values (B. field 1, B. field 2 ,....) example of www.2cto.com: Table Name: TR_RUNNING_MONITOR; field name: LAST_TASK_ROWID, LAST_CRAWL_DATE,
START_TIME, DOC_COUNT, HIT_COUNT, OP_TYPE, DOC_TYPE merge into TR_RUNNING_MONITOR a using (select? As LAST_TASK_ROWID ,? As LAST_CRAWL_DATE ,? As START_TIME ,? As DOC_COUNT,
? As HIT_COUNT ,? As OP_TYPE ,? As DOC_TYPE, sysdate as UPDATE_TIME from dual) B on (. OP_TYPE = B. OP_TYPE and. DOC_TYPE = B. DOC_TYPE) when matched then update set DOC_COUNT = DOC_COUNT, HIT_COUNT = HIT_COUNT, START_TIME = START_TIME, UPDATE_TIME
= UPDATE_TIME, LAST_CRAWL_DATE = LAST_CRAWL_DATE, expires = LAST_TASK_ROWID when not matched then insert (OP_TYPE, DOC_TYPE, DOC_COUNT, HIT_COUNT, START_TIME, UPDATE_TIME, LAST_CRAWL_DATE,
LAST_TASK_ROWID) values (B. OP_TYPE, B. DOC_TYPE, B. DOC_COUNT, B. HIT_COUNT, B. START_TIME, B. UPDATE_TIME,
B. LAST_CRAWL_DATE, B. LAST_TASK_ROWID)
Note: Use OP_TYPE and DOC_TYPE to compare the two fields in the table TR_RUNNING_MONITOR and perform the update at the same time,
Insert simultaneously