在线等待!!! 关于发号和自动计算!(100分)

  • 主题发起人 lemonloveyan
  • 开始时间
L

lemonloveyan

Unregistered / Unconfirmed
GUEST, unregistred user!
1。样根据当前数据集的条数而自动的给顺序编号?
比如 增加一条纪录 记录号为 1 一直下去直至记录号为5
当我删除一条纪录号为3的,记录号自动排序为1-4???
2。因 为主从表,怎样根据当前从数据集的金额变化自动计算主表的合计数呢??
非 dbgrid。
以上的2个问题怎么用代码的方法解决,在纪录没有保存到后台数据库的之前???
总的来说就是怎么灵活方便的获取当前活动数据集的某些字段的值???
在线等待,急着交工!!!
 
insert into table(id) values(select max(id)+1 from table)

主表可以按以下更新,但先要考虑从表的问题:
update table set id=id-1 where id>deletedId
 
自动编号是容易,但删除一条后重新排序就有点麻烦了,而且又是主从表
 
问题是我的数据并没有提交啊,只是Post 而已,根本就没有反应到数据库里边去啊!!
 
update tbl_p_combin set curno=curno-1 where curno>=:curno and per_id=:per_id

update tbl_p_combin set curno=curno+1 where curno=:n and per_id=:per_id

update tbl_p_combin set curno=curno-1 where id=:id and per_id=:per_id
 
只是当前的活动数据集,数据没有提交!
自动增加好办,就是删除之后是个问题!
 
没办法,如果是这样,只能循环,
如用的是SQL Server 2000,可考虑用以下约束
[ [ FOREIGN KEY ]
REFERENCES ref_table [ ( ref_column ) ]
[ ON DELETE { CASCADE | NO ACTION } ]
[ ON UPDATE { CASCADE | NO ACTION } ]
[ NOT FOR REPLICATION ]
 
update tbl_p_combin set curno=curno-1 where curno>=:curno and per_id=:per_id
update tbl_p_combin set curno=curno+1 where curno=:n and per_id=:per_id
update tbl_p_combin set curno=curno-1 where id=:id and per_id=:per_id
或者
[ [ FOREIGN KEY ]
REFERENCES ref_table [ ( ref_column ) ]
[ ON DELETE { CASCADE | NO ACTION } ]
[ ON UPDATE { CASCADE | NO ACTION } ]
[ NOT FOR REPLICATION ]

 
接受紫浪花和大家的答案!
 
顶部