table.DELETE_RANGE Function
Syntax
Arguments
- Filter_Expr
Optional. Default = current query or range. A character filter expression that evaluates to a logical value. If a Filter is included, the current query or range is ignored, and only records that satisfy the Filter are deleted.
Description
Delete a range of records in the table.
Discussion
The <TBL>.DELETE_RANGE() method is a high-level utility function used to delete selected records in a table. The operation is performed on the records in the table pointed to by the object pointer. Note : Do not use <TBL>.DELETE_RANGE()in a multi-user environment where other users may lock records within the range.
Example
This script deletes California customer records
dim tbl as P tbl = table.open("d:\a5\a_sports\customer.dbf") 'Perform a query to find California customers. query.filter = "State_prov = 'CA' " query.order = "Recno()" qry_ca_cust = tbl.query_create() 'Delete all records in current query by omitting the optional filter expression tbl.delete_range() tbl.close()
This script ignores the current range and deletes New York customers.
dim tbl as P tbl = table.open("d:\a5\a_sports\customer.dbf") 'Perform a query to find California customers. query.filter = "State_prov = 'CA' " query.order = "Recno()" query.options = "" qry_ca_cust = tbl.query_create() 'Delete all records in New York tbl.delete_range("State_prov = 'NY' ") tbl.close()
This script deletes all of the records in a table individually without using the .DELETE_RANGE() method.
dim tbl as P tbl = table.current() tbl.fetch_first() while .NOT. tbl.fetch_EOF() tbl.change_begin() tbl.delete() tbl.change_end(.T.) end while
This script compiles and then removes script source from a database.
dim tbl as P ' Make AEX a5_compile_scripts() ' Make and add new table to database file.copy("final.alb", "temp.dbf") file.copy("final.alm", "temp.fpt") file.copy("final.alx", "temp.cdx") file_add_to_db("temp.dbf") ' Remove scripts and UDFs tbl = table.open("temp") filter = "(type = 'scrp') .or. (type = 'gudf')" tbl.delete_range(filter) tbl.pack() tbl.close() ' Replace al* files with new dictionary file.copy("temp.dbf", "final.alb") file.copy("temp.fpt", "final.alm") file.copy("temp.cdx", "final.alx") ' Erase temp table table.erase("temp", .t.)
See Also