0

Goal: I am trying to retrieve records that were affected by UPDATE query.

Based on IBMs article I can use the following query:

SELECT empno, salary FROM FINAL TABLE
(UPDATE employee SET salary = salary * 1.10 WHERE job = 'CLERK')

However when I try to run similar query in database I get the following error:

[42601][-199] [SQL0199] Keyword UPDATE not expected. Valid tokens: INSERT.

  • 2
    You might want to indicate your Db2 for IBM i version (and reference documentation for that platform, not LUW). – mustaccio Mar 20 at 21:55
1

Looking at the Db2 for i 7.2 Knowledge Center, shows that only INSERT's are valid in data-change-table-references, not UPDATE's

https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_72/db2/rbafztabref.htm

data-change-table-reference

|----+-FINAL-+--TABLE--(--INSERT statement--)--+--------------------+----|
     '-NEW---'                                 '-correlation-clause-'     

If a data-change-table-reference is specified, the intermediate result table is the set of rows inserted by the INSERT statement.

The link you referenced in your original question is for DB2 for LUW (Linux, Unix and Windows) 9.7. This is essentially a different product than Db2 for i.

  • Thank you. This makes more sense now – Ruslan Mar 21 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.