News
Abstract
INSERT with remote SUBSELECT
Content
The INSERT SQL statement is enhanced to allow the subselect 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.
FROM X1423P2.SYSIBM.SYSDUMMY1)
CREATE ALIAS DATALIB.REMOTE_TABLE FOR x1423p2.SYSIBM.SYSDUMMY1
INSERT INTO DATALIB.MY_TEMP_TABLE
(SELECT CURRENT_SERVER CONCAT ' is the Server Name', IBMREQD
FROM DATALIB.REMOTE_TABLE)
SELECT * FROM DATALIB.MY_TEMP_TABLE
(same result as shown in Example 1)
Forr more information on this topic, refer to the "Inserting data from a remote database" section within the Database SQL Programming book.
Was this topic helpful?
Document Information
Modified date:
07 May 2022
UID
ibm11167430