很多时候,我们需要封存当前的SBO帐套、启用新的SBO帐套。SBO系统对象都具有很好的数据传递性,而自定义业务对象就麻烦了,即使设置其为可以Transfer,自定义的业务对象仍然无法在新的帐套中产生连贯的序列,甚至连序列都没法建立。
以下这几段Sql语句就是为了应该这种情况的,它有效的解决了上述的问题。至于为什么这个做,我相信经验丰富的SBO工程师们看看就很清楚了。
恩,是的,在此的OldDb就是Sql中老的Sbo帐套对应的数据库,而NewDb就是新帐套对应的数据库了。
__insert into [NewDb]..onnm (ObjectCode,Autokey,Dflt">Series)__select ObjectCode,Autokey,DfltSeries + maxSeries - minSeries + 1 newSeriesfrom [OldDb]..onnm a,(__select max(DfltSeries) maxSeries from [NewDb]..onnm) b,(__select min(DfltSeries) minSeries from [OldDb]..onnm where ObjectCode not in (__select objectcode from [NewDb]..onnm)) cwhere objectcode not in (__select ObjectCode from [NewDb]..onnm)go __insert into [NewDb]..nnm1(ObjectCode, Series, SeriesName, InitialNum, NextNumber, LastNum, BeginStr, EndStr, Remark, GroupCode, Locked, YearTransf, [Indicator],
Template, NumSize, FolioPref, NextFolio,DocSubType)__select a.ObjectCode, b.DfltSeries, a.SeriesName, a.InitialNum, a.NextNumber, a.LastNum, a.BeginStr, a.EndStr, a.Remark, a.GroupCode, a.Locked, a.YearTransf, a.[Indicator], a.Template, a.NumSize, a.FolioPref, a.NextFolio, a.DocSubTypeFROM [OldDb]..NNM1 a inner
join [NewDb]..onnm b . a.ObjectCode=b.ObjectCodeWHERE a.ObjectCode not in (__select ObjectCode FROM [NewDb]..nnm1)go __insert into [NewDb]..nnm2(ObjectCode, Series, DocSubType,UserSign)__select a.ObjectCode, b.DfltSeries, a.DocSubType,1FROM [OldDb]..NNM2 a inner join [NewDb]..onnm b . a.ObjectCode=b.ObjectCodeWHERE a.ObjectCode not in (__select ObjectCode FROM [NewDb]..nnm2)go __insert into [NewDb]..nnm3(ObjectCode, Series, DocSubType)__select a.ObjectCode, b.DfltSeries, a.DocSubTypeFROM [OldDb]..NNM3 a inner join [NewDb]..onnm b . a.ObjectCode=b.ObjectCodeWHERE a.ObjectCode not in (__select ObjectCode FROM [NewDb]..nnm3)go
在SBO 2005B和Sql Server 2000中成功实施通过。
本文出自 “富盛软件” 博客,请务必保留此出处http://foresun.blog.51cto.com/221037/128792