日期:2014-05-19  浏览次数:20695 次

高手帮忙看看这个存储过程!参数正确带进去,数据库不能插入...
CREATE   PROCEDURE   [insert_CFMap_Points_2]
(@ID_1   [varchar](8000),
  @FeatureID_2   [varchar](8000),
  @X_3   [varchar](8000),
  @Y_4 [varchar](8000),
  @parts_5 [varchar](1000))

AS  
DECLARE   @PointerPrev1   int
DECLARE   @PointerCurr1   int
DECLARE   @PointerPrev2   int
DECLARE   @PointerCurr2   int
DECLARE   @PointerPrev3   int
DECLARE   @PointerCurr3   int
DECLARE   @PointerPrev4   int
DECLARE   @PointerCurr4   int
DECLARE   @PointerPrev5   int
DECLARE   @PointerCurr5   int
DECLARE   @TID_1   varchar(50)
DECLARE   @TFeatureID_2   varchar(50)
DECLARE   @TX_3   float
DECLARE   @TY_4 float
DECLARE   @Tparts_5 int

Set   @PointerPrev1=1
Set   @PointerCurr1=1
Set   @PointerPrev2=1
Set   @PointerCurr2=1
Set   @PointerPrev3=1
Set   @PointerCurr3=1
Set   @PointerPrev4=1
Set   @PointerCurr4=1
Set   @PointerPrev5=1
Set   @PointerCurr5=1

        begin   transaction
        Set   NoCount   ON

        Set   @PointerCurr1=CharIndex( '| ',@ID_1,@PointerPrev1+1)
        Set   @TID_1   =cast(SUBSTRING(@ID_1,@PointerPrev1,@PointerCurr1-@PointerPrev1)   as   varchar)
        Set   @PointerCurr2=CharIndex( '| ',@FeatureID_2,@PointerPrev2+1)
        Set   @TFeatureID_2   =cast(SUBSTRING(@FeatureID_2,@PointerPrev2,@PointerCurr2-@PointerPrev2)   as   varchar)
        Set   @PointerCurr3=CharIndex( '| ',@X_3,@PointerPrev3+1)
        Set   @TX_3   =cast(SUBSTRING(@X_3,@PointerPrev3,@PointerCurr3-@PointerPrev3)   as   float)
        Set   @PointerCurr4=CharIndex( '| ',@Y_4,@PointerPrev4+1)
        Set   @TY_4   =cast(SUBSTRING(@Y_4,@PointerPrev4,@PointerCurr4-@PointerPrev4)   as   float)
        Set   @PointerCurr5=CharIndex( '| ',@parts_5,@PointerPrev5+1)
        Set   @Tparts_5   =cast(SUBSTRING(@parts_5,@PointerPrev5,@PointerCurr5-@PointerPrev5)   as   int)
        Insert   into   CFMap_Points     ([ID],[FeatureID],[X],[Y],   [parts])     Values(@TID_1,@TFeatureID_2,@TX_3,@TY_4,   @Tparts_5)
        SET   @PointerPrev1=   @PointerCurr1
        SET   @PointerPrev2=   @PointerCurr2
        SET   @PointerPrev3=   @PointerCurr3
        SET   @PointerPrev4=   @PointerCurr4
        SET   @PointerPrev5=   @PointerCurr5  
      while   (   (@PointerPrev1+1   <   LEN(@ID_1))   and   (@PointerPrev2+1   <   LEN(@FeatureID_2))   and   (@PointerPrev3+1   <   LEN(@X_3))   and   (@PointerPrev4+1   <   LEN(@Y_4))   and   (@PointerPrev5+1   <   LEN(@parts_5))   )
        Begin
    &nbs