DB2 MERGE statement error

I tried the following with several options, but I keep getting errors. Any way to get this fixed. DB2 10.1 (DB2 for z / OS V10)

For the next

MERGE INTO TRGT t
USING SRC s
ON (t.ACCTID=s.ACCTID AND s.SEQID=123)
WHEN MATCHED THEN
UPDATE SET
MyFlag = 'Y'

Error: Unexpected token "SRC" was found after ". Expected tokens may include:" (". SQLSTATE = 42601

SQLState: 42601 ErrorCode: -104


However for the next

MERGE INTO TRGT t
USING (SELECT SEQID, ACCTID FROM SRC WHERE SEQID=123) s
ON (t.ACCTID=s.ACCTID)
WHEN MATCHED THEN
UPDATE SET
MyFlag = 'Y'

Error: The use of the reserved word "SELECT" after "is invalid. Expected tokens may include:" VALUES. "SQLSTATE = 42601

SQLState: 42601 ErrorCode: -199

+4
source share
1 answer

( , ), DB2 for z/OS MERGE, VALUES. , , .

MERGE INTO TRGT t
USING (VALUES (:param1, :param2) FOR :paramNumRows) s
   ON (t.ACCTID=s.ACCTID)
 WHEN MATCHED THEN
     UPDATE SET MyFlag = 'Y'
+6

All Articles