getnextmodified( ) 函数示例

下面的示例演示了如何利用 getnextmodified( ) 函数判定表中哪一个记录已作了更改。为满足表缓冲的要求,将 multilocks 设置为 on。打开 testdate 数据库中的 customer 表,并调用 cursorsetprop( ) 函数,将缓冲方式设置为开放式表缓冲(5)。发出 skip 命令,把记录指针移动到第二个记录上,并用 replace 命令修改 cust_id 字段。从表的起始处开始,使用 getnextmodi fied(0) 显示从表中下一个被修改记录的记录号(2,第二个记录)。然后调用 tablerevert( ) 函数使表返回到原始状态,并且再次使用 getnextmodified(0) 被显示下一个修改的记录号(0,表示没有修改过记录)。

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

clear
skip && 把记录指针移到第二个记录上
replace cust_id with '***' && 更改字段内容
? getnextmodified(0) && 返回 2,第二个记录被修改过
= tablerevert(.t.) && 放弃对表的所有修改
? getnextmodified(0) && 返回0,没有记录被修改过