The FINAL TABLE clause is great for returning values from DML to DB2, for example:
SELECT id
FROM FINAL TABLE
(
INSERT INTO mySchema.myTable (val)
VALUES ('data')
)
However, there seems to be no way to store the results of this query in another table, storing the contents somewhere. For example, both of the following errors with the error "Link to the data change table is not allowed where indicated." (I am running DB2 for I v7.1):
CREATE TABLE mySchema.otherTable AS (
SELECT id
FROM FINAL TABLE
(
INSERT INTO mySchema.myTable (val)
VALUES ('data')
)
) WITH DATA
After creating mySchema.otherTable in a separate CREATE TABLE statement, this also fails:
INSERT INTO mySchema.otherTable (ID)
SELECT id
FROM FINAL TABLE
(
INSERT INTO mySchema.myTable (val)
VALUES ('data')
)
source
share