数据库是sqlserver2000,为了防止多人同时修改一条记录,打算在表中增加一个timestamp字段,实现逻辑如下
先查下
select tversion into :tv from tba where id=:id,
然后update的时候
update tba set xx=bb where where id=:id and tversion=:tv;
在判断下影响的行数,
如果小于1,则说明已经被别人更新了,
有2个问题
1 上面逻辑有问题?
2 timestamp 在pb里面对应说明字段类型?string?
------解决方案--------------------
1 上面逻辑有问题?
答:逻辑上没有问题
2 timestamp 在pb里面对应说明字段类型?string?
答:用datatime试试
------解决方案--------------------
哦,对的。
我在做WS 时,在SQL储过程里转换成varchar 处理过了的。