table.QUERY_FROM_RANGE Function

Syntax

Result_Flag as L = Query_From_Range()

Description

Create a query from the current range, if one is in effect - returns .T. if new query created.

Discussion

The <TBL>.QUERY_FROM_RANGE() method converts the current range into a query. A query is static, whereas a range is dynamic. You might want to convert a range to a query so as to get a count of the number of records in a range, or to prevent the range of records from changing dynamically. Result_Flag is .T. if the query was successfully created (i.e. a range was in effect), and is .F. if the query was not created (i.e. there was no range in effect)

Example

The following code generates two queries, then deletes them

tbl = table.open("customer")
Query.filter = "state = 'ma'"
indx = tbl.query_create()
Records1 = tbl.records_get()
Query.filter = "state = 'ca'"
indx = tbl.query_create()
Records2 = tbl.records_get()
tbl.query_detach_all()
'now, set the primary index to lastname order
tbl.index_primary_put("lastname")

See Also