I want to load a data in temp table in DB2. in syntax when i use ON COMMIT PRESERVE ROWS compiler throws an error:
Lookup Error - DB2 Database Error: ERROR [42601] [IBM][DB2/AIX64] SQL0104N An unexpected token "ON" was found following "P BY ACCOUNT_NUMBER)". Expected tokens may include: "".
When I replaced On commit preserve rows by definition only temp table is successfully created but I don't see my sub query data inserted in the temp table. Can you please help me where I am making mistake?
DECLARE GLOBAL TEMPORARY TABLE SESSION.TEMP_TABLE AS
(SELECT ACCOUNT_NUMBER, NET_AMOUNT
FROM SCHEMA.TABLE_NAME WHERE 1=1 AND COLUMN1='a') ON COMMIT PRESERVE ROWS;