begin transaction 命令示例

在下面示例中,打开数据库 testdata 的 customer 表,发出 begin transaction 命令来启动一个事务处理,接着显示 cust_id 和 company 字段内容。然后替换 company 字段内容,再显示新的平共处company 字段内容。发送 rollback 命令来恢复 company 字段的原来内容,然后再次显示 cust_id  和 company 字段的内容,这时的 company 字段保持原值。

open database (home( ) + 'samples\data\testdata.dbc')
begin transaction
use customer && 仅在 dbc 中支持事务处理
clear
list fields cust_id, company next 20
wait window 'press a key to change the company field'
replace all company with '***' && 更改 company 字段内容
clear
go top
list fields cust_id, company next 20
wait window 'press a key to restore the company field'
rollback && 恢复字段的原来内容
clear
go top
list fields cust_id, company next 20
wait window 'press a key to exit'
clear
close all