INSERT with remote SUBSELECT
The INSERT SQL statement is enhanced to allow the sub-select to reference a single remote database which is different than the current server connection. Other SQL statements remain restricted to a single database reference per statement.
An implicit remote connection is established and used by DB2 for i for the duration of the subselect. The subselect must avoid referencing more than one target database. Either explicit three part names or implicit remote names using an SQL alias can be used within the sub-select.
CREATE ALIAS DATALIB.REMOTE_TABLE FOR x1423p2.SYSIBM.SYSDUMMY1
INSERT INTO DATALIB.MY_TEMP_TABLE
(SELECT CURRENT_SERVER CONCAT ' is the Server Name', IBMREQD
SELECT * FROM DATALIB.MY_TEMP_TABLE
(same result as shown in Example 1)
To discover more information on this topic, refer to the "Inserting data from a remote database" section within the Database SQL Programming book.
15 January 2020