阅读:11076回复:1
oracle 存在则更新,不存在则插入
如题,,,,
|
|
|
沙发#
发布于:2016-09-10 20:35
MERGE:合并新增和修改
merge,适用于oracle
比如:如果我要批量上传文件(文件名唯一),如果文件存在则更新,否则插入; MERGE INTO PWFA_UPLOAD_FILE T1 USING (SELECT '$P.filename' filename FROM DUAL) T2 (这一句其实没什么用) ON (T1.filename = '$P.filename') WHEN MATCHED THEN UPDATE SET T1.servername = '$P.servername', T1.updatetime = sysdate, T1.updateuserid = '$S.id', T1.updateusername = '$S.username' WHEN NOT MATCHED THEN INSERT (id, yearmonth, org_code, reportcode, filename, servername, isread, userid, username, departid, departname, opdate, filepath, year, periods, updatetime) VALUES ('$P.id', '$P.yearmonth', '$P.org_code', '$P.reportcode', '$P.filename', '$P.servername', '否', '$S.id', '$S.username', '$S.depart[0].id', '$S.depart[0].text', sysdate, '/data/jboss/FIMS/FILEDATA', '$P.year', '$P.periods', sysdate) 其他情况可查找merge详细使用方法,当然还有其他的解决办法; |
|
|