Chapter Contents

Previous

Next
SAS/CONNECT User's Guide

Example 1. RSPT Services: Querying a Table in DB2


Purpose

This example shows how to query a DB2 table that is located on a remote host by using SQL statements issued from a local host SAS session.


Program

The following sequence of statements would be used in an OS/390 SAS session to establish a connection 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 from an OS/2 SAS session by using RSPT by means of a SAS server in a remote session under OS/390:

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');

Use the AS alias clause in the CONNECT TO statement to give the same name to the connection to the remote DBMS as it would have if you connected directly to it. This 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');


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.