子段:id 流水号 ,cid 序号 ,name 名称
比如说共有100条纪录,删除其中一条纪录,让cid自动减一,而其他的不变,如果一个cid为10,删除一个之后,它的值变为9。
这样的代价如何?值不值得?
代价可能很高,本人认为不值得。
如果非要这么处理,用数据库的触发器实现。
int flag,cid,id,a,b,i
select id into :id from table where id=:sle_1.text;
if id<>integer(sle_1.text) then
messagebox("","该纪录已经被删除!")
else
select max(c_id) into :a from table;
select c_id into :b from table where id=:sle_1.text;
delete from table where id=:sle_1.text;
id=integer(sle_1.text)
for i=b to a
id=id+1
select c_id into :cid from table where id=:id;
cid=(cid)-1
update table set c_id=:cid where id=:id;
next
dw_1.retrieve()
end if
这样你看看行不行。
如果需要,就值得。但是如果数据很多,几千条,几万条,则效率会降低很多。你试一试一下增加2000条纪录所需的时间,还有上面所需的时间。
要考虑的情况很多,建议不进行调整。