Example 1. RSPT Services: Querying a Table in DB2

Purpose

This example shows how to query a DB2 table that is located on a server by using SQL statements issued from a client session.

Program

This code is used in a z/OS client session to connect to DB2 and query the table SYSIBM.SYSTABLES:
connect to db2 (ssid=db2p);

select * from connection to db2
   (select name, creator, colcount
       from sysibm.systables
       where creator='THOMPSON' or 
             creator='JONES');
The same connection and query could be performed in a Windows client session by using RSPT by means of a z/OS server session:
connect to remote 
   (server=rmt dbms=db2 dbmsarg=(ssid=db2p));
select * from connection to remote
   (select name, creator, colcount
       from sysibm.systables
       where creator='THOMPSON' or 
             creator='JONES');
Using the AS alias clause in the CONNECT TO statement gives the connection name to the remote DBMS as if connected directly to it. Using this alias enables you to use queries without changing the FROM CONNECTION TO clause:
connect to remote as db2 
   (server=rmt dbms=db2 dbmsarg=(ssid=db2p));

select * from connection to db2
    (select name, creator, colcount
        from sysibm.systables
        where creator='THOMPSON' or 
              creator='JONES');