tablerevert( ) 函数示例

下面的示例显示了如何使用 tablerevert( ) 函数放弃对缓冲表的修改。首先把 multilocks 设置成 on 以请求表缓冲;然后打开 testdata 数据库中的 customer 表,用 cursoretprop( ) 函数把缓冲方式设置为开放式表缓冲 (5)。首先显示 cust_id 字段值,再用 replace 命令修改 cust_id 字段,显示新的 cust_id 字段值,最后使用 tablerevert( ) 函数把表恢复成原来状态(可以用 tableupdate( ) 函数实施此更改),显示恢复的 cust_id 字段值。

close databases
set multilocks on && 对于表缓冲必须为 on
set path to (home( ) + 'samples\data\') && 设置数据库路径
open database testdata && 打开“testdata”数据库
use customer && 打开“customer”表
= cursorsetprop('buffering', 5, 'customer') && 启用表缓冲

clear
? 'original cust_id value: '
?? cust_id && 显示当前“cust_id”的值
replace cust_id with '***' && 改变字段的内容
? 'new cust_id value: '
?? cust_id && 显示新的“cust_id”值
= tablerevert(.t.) && 放弃所有表的更改
? 'reverted cust_id value: '

?? cust_id && 显示恢复的“cust_id”的值