Executing a select statement will return the number of rows found and set the in memory active list of keys which can be accessed using a list statement.
@ID contains the name of the record key, use this field in you comparison criteria.
SELECT INVENTORY WITH @ID GT 100 AND @ID LT 200
@ID contains the name of the record key, use this field in you comparison criteria. For example find all window source code belonging to the EXAMPLES app. The right bracket operator means 'beginning with'.
SELECT SYSREPOSWINS WITH @ID ] "EXAMPLES"
Conversely the left bracket operator means 'ending with' and the example below will return all windows in all applications named CUSTOMER_INFO.
SELECT SYSREPOSWINS WITH @ID [ "CUSTOMER_INFO"
@ID contains the name of the record key, use this field in you comparison criteria. For example find all window source code belonging to the EXAMPLES app.
SELECT SYSREPOSWINS WITH @ID ] "EXAMPLES*"
The keyword ALL refers to the entire contents of a record. Use the keyword all in conjunction with the comparison keyword CONTAINING or []
SELECT INVENTORY WITH ALL CONTAINING "Needle"
SELECT INVENTORY WITH ALL [] "Needle"
SELECT INVENTORY WITH LCOST LE 0 OR WITH PCOST LE 0 OR WITH LPRICE LE 0
SELECT 100 INVENTORY
The active list of keys can be saved or loaded from a record. The sort order of the keys depends on the BY and BY-DSND operators in the select statement used to generate the list of keys.
SAVELIST MyList
GETLIST MyList
The system will report the number of keys in the list but does not guarantee the keys in the list are unique or the records still exist.
If you have a @FM list of keys and want to turn it into a saved list for use at the TCL:
Declare Subroutine Make.List, Save_Select
TABLE_NAME = 'CUSTOMERS'
Open TABLE_NAME To TblHnd Else Debug
Open "DICT.":TABLE_NAME To DictHnd Else Debug
Make.List(0,Keys,TblHnd,DictHnd)
Save_Select('', 'MyList', '', '')
These commands report on the records in the active list which can be set by SELECT or GETLIST.
LIST TABLENAME BY @ID col1 col2 col3 ... (G
LIST SYSREPOS @ID JUSTLEN 50 ID-SUPP
LIST SYSREPOS UPDATED BY-DSND UPDATED
LIST SYSREPOS UPDATED BY UPDATED
To sort by more than one field repeat the BY or BY-DSND statement.
LIST SYSREPOS UPDATED BY UPDATED BY @ID
LIST 100 INVENTORY
Note: When limiting the number of records returned and using sort criteria it's important to remember sorting is performed after the limit. Normally in SQL sorting occurs on the result set and the limit statement is used to return a subset of the result. In OpenInsight the limit statement occurs before the result set is sorted. For instance, listing 100 rows sorted by date will return different results than listing 10,000 rows sorted the same way.
LIST INVOICES PARTNO LIMIT PARTNO = 1234 QTY PRICE WITH DATE > '5/1/18' AND WITH PARTNO = 1234 BY-DSND DATE
Assuming PARTNO is a multivalue field the LIMIT PARTNO = 1234 will show only values that match PARTNO = 1234. Without this statement all of the PARTNO values would be listed as long as the DATE selection criteria passed and the invoice had at least one PARTNO matchin 1234. THe LIMIT command further specifies which matching multivalue rows should be displayed.
SELECT and LIST statements both return the correct results but when using a statement with symbolics it is helpful to use SELECT to ensure symbolic fields don't get needlessly evaluated. Given the statement where DAYS_DUE is a symbolic:
LIST PAYABLES WITH VENDORID = 300 BY DAYS_DUE NAME ADDRESS DAYS_DUE
DAYS_DUE will be evaluated twice, once for sorting and again for display. Using this statement in RLIST to get the results in your program will return the same results but it's more efficent (at a minimum) to change the statement to:
SELECT PAYABLES WITH VENDORID = 300 BY DAYS_DUE NAME ADDRESS DAYS_DUE
In this case even though DAYS_DUE is listed twice it will only be evaluated once during the sort because RLIST knows a SELECT statement will not display any data so it ignores the NAME, ADDRESS, and DAYS_DUE display columns.