事故的效果 begin try
begin tran
If @RowCnt1 > 0
Begin Update EnergyDataSumByYearN Set SumQty = SumQty + @Qty
Where MeterNo = @MeterNo And MeterType = @MeterType And DAYear = @DAYear ;
End
Else
Begin Insert EnergyDataSumByYearN(MeterNo,MeterType,DAYear,SumQty,Unit)
Select @MeterNo,@MeterType,@DAYear,@Qty,@Unit;
End
If @RowCnt2 > 0
Begin Update EnergyDataSumByMonthN Set SumQty = SumQty + @Qty
Where MeterNo = @MeterNo And MeterType = @MeterType And DAYear = @DAYear And DAMonth = @DAMonth;
End
Else
Begin Insert EnergyDataSumByMonthN(MeterNo,MeterType,DAYear,DAMonth,SumQty,Unit)
Select @MeterNo,@MeterType,@DAYear,@DAMonth,@Qty,@Unit;
End
If @RowCnt3 > 0
Begin Update EnergyDataSumByDayN Set SumQty = SumQty + @Qty
Where MeterNo = @MeterNo And MeterType = @MeterType And DAYear = @DAYear And DAMonth = @DAMonth And DADay = @DADay;
End
Else
Begin Insert EnergyDataSumByDayN(MeterNo,MeterType,DAYear,DAMonth,DADay,SumQty,Unit)
Select @MeterNo,@MeterType,@DAYear,@DAMonth,@DADay,@Qty,@Unit;
End
If @RowCnt4 > 0
Begin Update EnergyDataSumByHourN Set SumQty = SumQty + @Qty
Where MeterNo = @MeterNo And MeterType = @MeterType And DADay = IsNull(@DAYear,'') + IsNull(@DAMonth,'') + IsNull(@DADay,'')
And DAHour = @DAHour ;
End
Else
Begin Insert EnergyDataSumByHourN(MeterNo,MeterType,DADay,DAHour,SumQty,Unit)
Select @MeterNo,@MeterType,IsNull(@DAYear,'') + IsNull(@DAMonth,'') + IsNull(@DADay,''),@DAHour,@Qty,@Unit;
End
--Exec Usp_TransferDAListToEnergyData @MeterNo,@MeterType,@DATime,@Qty,@Unit end try
begin catch
rollback tran --处理失败 数据回滚
end catch