上图是商品资料表ptype表。如何做到,增删改ptype表后,也同步更新下图的T_Jxc_PtypeUnit表呢?补充一下程序带存储过程能不能利用上?:USE
GO
/****** Object: StoredProcedure . Script Date: 01/06/2021 13:22:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
ALTER Procedure .
(
@PtypeId nVarchar(50),
@nUnit tinyint,
@UnitName nVarchar(8),
@UnitRate Numeric(18, 8),
@RetailPrice Numeric(18, 4),
@MinSalePrice Numeric(18, 4),
@DefaultPrice Numeric(18, 4),
@Barcode nVarchar(50),
@TradePrice1 Numeric(18, 4),
@TradePrice2 Numeric(18, 4),
@TradePrice3 Numeric(18, 4),
@TradePrice4 Numeric(18, 4),
@TradePrice5 Numeric(18, 4),
@TradePrice6 Numeric(18, 4),
@TradePrice7 Numeric(18, 4),
@TradePrice8 Numeric(18, 4),
@TradePrice9 Numeric(18, 4),
@TradePrice10 Numeric(18, 4),
@TradePrice11 Numeric(18, 4),
@TradePrice12 Numeric(18, 4),
@TradePrice13 Numeric(18, 4),
@TradePrice14 Numeric(18, 4),
@TradePrice15 Numeric(18, 4)
)
AS
SET NOCOUNT ON
Select @PtypeId = IsNull(@PtypeId, '')
Select @UnitName = IsNull(@UnitName, '')
Select @Barcode = IsNull(@Barcode, '')
if exists(Select 1 From T_Jxc_PtypeUnit Where PtypeId = @PtypeId and nUnit = @nUnit)
Update T_Jxc_PtypeUnit Set UnitName = @UnitName, UnitRate = @UnitRate, RetailPrice = @RetailPrice, MinSalePrice = @MinSalePrice, DefaultPrice = @DefaultPrice, BarCode = @Barcode,
TradePrice1 = @TradePrice1, TradePrice2 = @TradePrice2, TradePrice3 = @TradePrice3, TradePrice4 = @TradePrice4, TradePrice5 = @TradePrice5, TradePrice6 = @TradePrice6,
TradePrice7 = @TradePrice7, TradePrice8 = @TradePrice8, TradePrice9 = @TradePrice9, TradePrice10 = @TradePrice10, TradePrice11 = @TradePrice11, TradePrice12 = @TradePrice12,
TradePrice13 = @TradePrice13, TradePrice14 = @TradePrice14, TradePrice15 = @TradePrice15
Where PtypeId = @PtypeId and nUnit = @nUnit
else
Insert Into T_Jxc_PtypeUnit(PtypeId, nUnit, UnitName, UnitRate, RetailPrice, MinSalePrice, DefaultPrice, BarCode, TradePrice1, TradePrice2, TradePrice3, TradePrice4,
TradePrice5, TradePrice6, TradePrice7, TradePrice8, TradePrice9, TradePrice10, TradePrice11, TradePrice12, TradePrice13, TradePrice14, TradePrice15)
Values(@PtypeId, @nUnit, @UnitName, @UnitRate, @RetailPrice, @MinSalePrice, @DefaultPrice, @Barcode, @TradePrice1, @TradePrice2, @TradePrice3, @TradePrice4,
@TradePrice5, @TradePrice6, @TradePrice7, @TradePrice8, @TradePrice9, @TradePrice10, @TradePrice11, @TradePrice12, @TradePrice13, @TradePrice14, @TradePrice15)补充以下两表的结构和数据,会的大佬帮忙写一下语句!谢谢!T_Jxc_PtypeUnit.sqlptype.sql