SELECT Command

The SELECT command creates a temporary select-list of file items to be processed by the next TCL or INFO/ACCESS statement, or by other processors such as the Editor, mvBASIC, or PROC. Creating a select-list is a useful way to define and operate on a subset of items in a database.

Format

SELECT [DICT] filename [item-list] [selection] [output]

Parameter(s)

DICT

Specifies the file dictionary.

filename

Name of the file.

item-list

List of individual item-IDs that you want to select or compare against specified criteria. Enclose each item-ID in single quotes. If you do not specify an item-list, the SELECT command selects all items in filename.

selection

Specifies one or more conditions that an item must meet to be included in the select-list. For a complete description of selection expression syntax, see the LIST Command.

output

Name of an attribute whose values are to be selected. Each value becomes a separate item-ID in the select-list.

Description

The SELECT command creates a temporary select-list containing item-IDs of the items specified in the item-list or the selection criteria. The items referenced by the select-list are processed by the next command you execute. For instance, before invoking the Editor you might create a select-list as a way of specifying which items you want to edit.

CAUTION

Only the statement immediately following the SELECT statement has access to the select-list. In other words, you must use the select-list immediately, or you will lose it!

To permanently save the select-list, use the SAVE-LIST command. Once a select-list is saved, you can retrieve it at any time with the GET-LIST command.

A select-list can reference data in any file, not just the file specified in the original SELECT statement. If two files have similar items with the same item-IDs, you can create a select-list from one file, then use it to operate on items from the other file.

Creating a Select-list

The following example illustrates how to create a select-list from one file and use it to access data in another file.

Assume a file called CUSTOMER.INACTIVE contains the item-IDs of customers with inactive accounts. You can create a select-list of these item-IDs and then retrieve the customers’ names and addresses from the CUSTOMERS file:

>SELECT CUSTOMERS.INACTIVE

41 ITEMS SELECTED.

>LIST CUSTOMERS LAST-NAME FIRST-NAME STREET CITY STATE

 .

 .

 .

The next example creates a select-list of dictionary items that define attribute 3 of the ORDERS file. Once the select-list has been created, the Editor is used to display the first item selected:

>SELECT DICT ORDERS WITH A/AMC = 3

 

3  ITEMS SELECTED.

>ED DICT ORDERS

TITLE

TOP

.P

001 S

002 1

003

004

005

006

007

008 TBOOK-CATALOG;C;;2

009 T

010 35

EOI 010

.