Example 4. RLS: An SCL Program That Uses the WHERE Statement


This example is an excerpt from an SCL program that uses RLS to query a remote reservation database. Reservations are selected based on the value that is stored in the variable RESNUM. The use of the WHERE clause in this example is important because the WHERE clause is applied in the server session before any data is transferred. As a result, only the observations that meet the criteria are moved to the client session.
This example is a good use of RLS because (as in the previous example) it involves transaction-type processing and enables the client GUI to be used for data entry on the selected observations in the database.
However, if you were to use the SCL LOCATEC function, every observation would be transferred to the client session and compared against the specified criteria. The response time might be poor. These alternative programming choices emphasize the importance of being aware of the amount of data that the client session requests and minimizing this amount when using RLS.


signon apex;
libname master REMOTE "hq.prod.data" server=apex;
 rdsid = open("master.reserv", 'u');
 wherecls="resnum=" || "'" || resnum || "'";
   rc = where(rdsid, wherecls);
   call set(rdsid);
   rc = fetchobs(rdsid, 1);
1 Opens the remote database.
2 Builds and applies the WHERE clause to accelerate retrieval.