Using the SELECT Verb with the Data Server

To ensure optimum performance when accessing remote files via the SELECT verb, specify the full path name of the remote file, complete with the name of the network host. It is particularly important to include the network host name in the FROM clause of a SELECT statement due to the large number of I/O operations involved with selecting and sorting. This enables the remote system (with the PRO/5 Data Server) to perform all of the necessary I/O operations locally and return only the requested data over the network connection, which results in reduced network traffic and improved performance.

Relying on a PREFIX to locate the remote file causes the SELECT to be performed locally, which places heavier demands on the network and increases response time. See the following examples:

Preferred Example

Discouraged Example

SELECT (1) REC$ FROM "/<server>remotefile"

SELECT (1) REC$ FROM "remotefile"

Observe the following guidelines for using the SELECT verb with the Data Server:

On multi-tasking systems, PRO/5 allocates a background user slot for each active SELECT. See User Limits and User Numbers in the PRO/5 Installation and Configuration Guide.

Under the UNIX operating system, the SELECT verb requires two semaphores and one shared memory segment for each active SELECT.

In the single-user MS-DOS version of PRO/5, the SELECT execution is deferred until a READ command is executed on the channel. For SELECT commands that include SORTBY parameters, the entire file must be sorted before the first record can be read. If unusual errors occur on the READ, the error may refer to the actual SELECT usage.

The TMPDIR environment variable should be set in the shell of the process that is performing the SELECT. If the PRO/5 client is performing the SELECT, TMPDIR should be set in its shell. If the SELECT is to be performed via the Data Server, TMPDIR should be set before the Data Server is invoked. If the Data Server is invoked via a startup script, the script should set TMPDIR before invoking the Data Server.

Example

In the following example, records in the master file that have a balance field greater than the limit field are selected from the file and sorted in order of increasing balance. The MODE="BLOCK=200" sets up a 200 record buffer between the SELECT process and the main PRO/5 process. The READ RECORD in statement 2010 reads the sorted records from the buffer, returning the fields as specified in the SELECT statement, via the SELREC$ template.

The WHERE expression parentheses in line 1010 are included for readability only and are not required.

1000 DIM REC$:"CUST_NUM:C(7),NAME:C(35),ADDRESS1:(35)
1000:,ADDRESS2:C(35),CITY:C(35),STATE:C(2),ZIP:N(5),
1000:PHONE:C(10),OPEN_DATE:C(8),LAST_PAY_DATE:C(8),
1000:LIMIT:N(7),BALANCE:N(7)"
1010 SELECT(ARMAST,MODE="BLOCK=200")REC$:REC.CUST_
1010:NUM$,REC.NAME$,REC.PHONE$,REC.LIMIT,REC.BALANCE
1010:FROM ARMASTER$ WHERE (REC.BALANCE>REC.LIMIT)
1010:SORTBY ADJN(REC.BALANCE)

2000 FIN$=FIN(ARMAST)
2005 DIM SELREC$:FIN$(65)
2010 READ RECORD(ARMAST,END=4000)SELREC$