19.08.2015 Views

DB2 9 & 10 for z/OS Overview

DB2 9 & 10 for zOS Overview - The Open Systems Group

DB2 9 & 10 for zOS Overview - The Open Systems Group

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Migration Planning WorkshopSelect from Update, Delete, and MergeSELECT athlete, score FROM FINAL TABLE(UPDATE events SET SCORE=SCORE+<strong>10</strong>WHERE EVENT=‘BOXING’);SELECT MEMBER_ID, UPSERT_INDICATOR FROM FINAL TABLE(MERGE INTO MEMBER_PROFILE AS AINCLUDE (UPSERT_INDICATOR CHAR(1))USING (VALUES (:col1, :col2, :col3) ) AS B(MEMBER_ID, MEMBER_NAME, MEAL_PREFERENCE)ON (A.MEMBER_ID = B.MEMBER_ID)WHEN MATCHED THENUPDATE SET A.MEMBER_NAME = B.MEMBER_NAME,A.MEAL_PREFERENCE = B.MEAL_PREFERENCE,UPSERT_INDICATOR = 'U'WHEN NOT MATCHED THENINSERT (MEMBER_ID,MEMBER_NAME,MEAL_PREFERENCE,UPSERT_INDICATOR)VALUES (B.MEMBER_ID, B.MEMBER_NAME, B.MEAL_PREFERENCE, 'I')NOT ATOMIC CONTINUE ON SQLEXCEPTION);• First example shows SELECT returning data from the nested UPDATE• Second example shows SELECT returning data from the nested MERGE with an INCLUDEcolumn.– This include column returns the compare column from the ON clause and an indicator of whether therow was Updated or Inserted.11© 2011 IBM Corporation

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!