日期:2014-05-17 浏览次数:20378 次
ALTER procedure [dbo].[UpdatePrice]--更新产品价格
(
--价格信息
@RowCounts int=0 output,--返回受影响的行数
@FactoryPrice Money = 0,--出厂价格
@BasicUnit_1 Decimal = 0,
@BasicUnit_2 Decimal = 0,
@BasicUnit_3 Decimal = 0,
@BasicUnit_4 Decimal = 0,
@BasicUnit_5 Decimal = 0,
@BasicUnit_6 Decimal = 0,
@Unit2_1 Decimal = 0,--包装2价格
@Unit2_2 Decimal = 0,
@Unit2_3 Decimal = 0,
@Unit2_4 Decimal = 0,
@Unit2_5 Decimal = 0,
@Unit2_6 Decimal = 0,
@Unit3_1 Decimal = 0,--包装3价格
@Unit3_2 Decimal = 0,
@Unit3_3 Decimal = 0,
@Unit3_4 Decimal = 0,
@Unit3_5 Decimal = 0,
@Unit3_6 Decimal = 0,
@strWhere varchar(1000)
)
AS
SET NOCOUNT ON
SET ANSI_WARNINGS OFF
SET XACT_ABORT ON
DECLARE @Sql VARCHAR(1000)
CREATE TABLE #TempTable (ProductID INT)
SET @Sql = 'INSERT INTO #TempTable (ProductID) SELECT (ProductID) FROM V_Products WHERE '+ @strWhere
EXEC(@Sql)
BEGIN TRAN
SET @RowCounts = @@RowCount
if(@FactoryPrice != 0)
begin
UPDATE ProductPrice SET FactoryPrice=@FactoryPrice where ProductID IN (select ProductID from #TempTable)
SET @RowCounts = @RowCounts + @@RowCount
end
----------------包装单位1价格----------------------------
IF ISNULL(@BasicUnit_1, 0) != 0
BEGIN
UPDATE ProductPrice SET BasicUnit_1 = ROUND((FactoryPrice * @BasicUnit_1),2) where ProductID IN (select ProductID from #TempTable)
SET @RowCounts = @RowCounts + @@RowCount
END
COMMIT TRAN
PRINT(@RowCounts)