MATCHED 用法

 BEGIN
		 MERGE PGENIUS..DISC_CLS_FND AS TARGET
		USING (SELECT SEQ,ISVALID, DISC_ID, DISC_CLS_CODE,DECLAREDATE
				FROM #INSERTED_DISC_CLS WHERE DISC_TYPE=2) AS SOURCE (SEQ,ISVALID,DISC_ID, DISC_CLS_CODE,DECLAREDATE)
		ON (TARGET.DISC_ID = SOURCE.DISC_ID  and target.Cls_code=source.disc_cls_code)
		WHEN MATCHED THEN 
			UPDATE SET MTIME =GETDATE()
						,ISVALID=SOURCE.ISVALID
						,DISC_ID=SOURCE.DISC_ID
						,CLS_CODE    =source.DISC_CLS_CODE    
						,DECLAREDATE     =source.DECLAREDATE  

		WHEN NOT MATCHED THEN	
			INSERT ( SEQ,MTIME,ISVALID, DISC_ID,CLS_CODE,DECLAREDATE)
			VALUES (SOURCE.SEQ,GETDATE(),SOURCE.ISVALID,SOURCE.DISC_ID,source.DISC_CLS_CODE,DECLAREDATE) 
			;
	 END

  

上一篇:Python-魔术方法


下一篇:BZOJ2298: [HAOI2011]problem a