On 17-Oct-2014 10:19 -0500, Darryl Freinkel wrote:
I need to be able to read a remote table and update a local table.
In a followup reply, v5r4 was revealed as the VRM; of course in that
case, what features [e.g. three-part naming] have been made available on
newer releases are probably moot.?
I have set up the remote database entries and have used connect. What
I cannot find documentation on is how to use 2 files on different
machines.
When I connect to system B, all the tables are in system B.
In a program, the data that previously had been obtained using a
FETCH from the remote connection [e.g. after CONNECT TO] would be the
source of data used for the INSERT performed after a SET CONNECTION to
the local system. The query will have run on and the data fetched from,
that remote system. The insert runs on the local system and the data is
local to the program. To get all of the data [best done in multi-row
fetches] and then perform the inserts [best done as multi-row inserts],
the SET CONNECTION would need to switch back-and-forth between the
remote [for FETCH] requests and local [for INSERT] requests, until the
end of data.
Is there a way to do a
select from system B and insert into system A ?
Example:
Insert into fileA /* on system A */
( select * from FileA /* on system B */ )
Aside from writing an SQL program, the following are two more direct
ways; note that the latter requires an interactive session\request:
The Start QM Query (STRQMQRY) feature supports an Output File
(OUTFILE) parameter. Directing the output to the output file, functions
as an effective INSERT INTO to a local file; if the output file does not
exist, IIRC, the output database file as an SQL TABLE. The SELECT would
be coded for the *QMQRY object, and the request to obtain the selected
data from the remote database and /insert/ the data into the named
TABLE, would be something like:
STRQMQRY QMQRY(theQuery) OUTPUT(*OUTFILE) OUTFILE(outLib/tableName)
OUTMBR(*FIRST *ADD) RDB(theRDBname)
The Start SQL (STRSQL) feature similarly supports an Output File
feature; the capability is established via the F13=Services, from which
the first option is to set the output device and settings. After the
CONNECT to the remote database, when the query is run, the output from
that query would be directed to the named output file; in this case, the
target output file, if the file did not already exist, would IIRC, be
created as a non-SQL externally described database file.
Each of writing a program, the STRQMQRY, and the STRSQL, should be
available on v5r4. The STRQMQRY would be available [Create QM Query
(CRTQMQRY) from a source vs the interactive Start QM (STRQM) would be
used to define the SELECT query] even if the 57##ST1 product is not
installed, whereas the other two options would not be [directly]
available without that LPP being installed.
As an Amazon Associate we earn from qualifying purchases.