MERGE INTO KM18_SJCONTROL K
USING (
SELECT
:HIN_SYBASYO_CD AS HIN_SYBASYO_CD
,:SYUKA_SEND_DATE AS SYUKA_SEND_DATE
,:SYUKA_SEND_TIME AS SYUKA_SEND_TIME
,:SYUKA_SEND_PC AS SYUKA_SEND_PC
,:SYORI_FLG AS SYORI_FLG
,:MK_DATE AS MK_DATE
,:MK_TIME AS MK_TIME
,:UP_DATE AS UP_DATE
,:UP_TIME AS UP_TIME
FROM DUAL
) D
ON (K.HIN_SYBASYO_CD=D.HIN_SYBASYO_CD)
WHEN MATCHED THEN UPDATE
SET
SYUKA_SEND_DATE=D.SYUKA_SEND_DATE
,SYUKA_SEND_TIME=D.SYUKA_SEND_TIME
,SYUKA_SEND_PC=D.SYUKA_SEND_PC
,SYORI_FLG=D.SYORI_FLG
,MK_DATE=D.MK_DATE
,MK_TIME=D.MK_TIME
,UP_DATE=D.UP_DATE
,UP_TIME=D.UP_TIME
WHEN NOT MATCHED THEN INSERT (
HIN_SYBASYO_CD
,SYUKA_SEND_DATE
,SYUKA_SEND_TIME
,SYUKA_SEND_PC
,SYORI_FLG
,MK_DATE
,MK_TIME
,UP_DATE
,UP_TIME)
VALUES (
D.HIN_SYBASYO_CD
,D.SYUKA_SEND_DATE
,D.SYUKA_SEND_TIME
,D.SYUKA_SEND_PC
,D.SYORI_FLG
,D.MK_DATE
,D.MK_TIME
,D.UP_DATE
,D.UP_TIME
)
一条完整的merge语句,在按照原有的数据更新的时候(并不知道有没有这条数据存在),用merge语句可以解决。