Maybe a simple question, but what is the best way to move (not copy!) data
from one table to another?
Meaning, I want to insert a set of rows from one table to another *and*
delete all of the same rows from the source table.
I tried the following, but DB2 does not allow it:
INSERT INTO FILM_TRANSACTIONS2
SELECT *
FROM OLD TABLE (
DELETE FROM FILM.FILM_TRANSACTIONS
WHERE POST_DATE = CURRENT_DATE
);
DB2 says:
SQL20165N An SQL data change statement within a FROM clause is not allowed
in the context in which it was specified.
Obviously I can do this:
INSERT INTO FILM_TRANSACTIONS2
SELECT *
FROM FILM.FILM_TRANSACTIONS
WHERE POST_DATE = CURRENT_DATE;
DELETE FROM FILM.FILM_TRANSACTIONS
WHERE POST_DATE = CURRENT_DATE;
But I thought it might be better to do both in a single statement.
(Maybe not!)
Thanks,
Frank