如果更新的没有超过100的话,可以使用lpad函数帮你。update a set intid=lpad(intid+1,'2','0') 或者update a set intid=case when intid>0 and intid<9 then lpad(intid+1,2,'0') else to_char(intid+4) end
如果想要算出来的结果和原来位数相同 固定位数 左边加0就可以了 update table set A=lpad(A+1,length(A),0) where ...
如果想要算出来的结果和原来位数相同 固定位数 左边加0就可以了SQL code update table set A=lpad(A+1,length(A),0) where ...这样不行!99到100的时候会出问题
update table set A=lpad(A+1,length(A)-length(to_char(to_number(A))) + 1 ,0) where ....
判断下吧 这样看可以不 update table set A=lpad(A+1,decode(sign(length(A+1)-length(A)),1,length(A+1),length(A)),0) where ...
对不起,我在4#的回复是错的。下面的应该可以: update table set A=lpad(A+1,greatest(length(A),length(A+1)),0) where
或者update a set intid=case when intid>0 and intid<9 then lpad(intid+1,2,'0')
else to_char(intid+4) end
update table set A=lpad(A+1,length(A),0) where ...
update table set A=lpad(A+1,length(A),0) where ...这样不行!99到100的时候会出问题
where ....
update table set A=lpad(A+1,decode(sign(length(A+1)-length(A)),1,length(A+1),length(A)),0) where ...