34,575
社区成员
发帖
与我相关
我的任务
分享
create procedure udsp_InsertTradeContractQualityDetail
@TradeContractNumber nvarchar(32),
@FreightBreedName nvarchar(16),
@FreightBreedProductionArea nvarchar(16),
@FreightBreedAmount real,
@UnitPrice real,
@DWFRL real,
@HFF real,
@HLL real,
@SF real,
@HZ real
as
begin
declare @Index smallint
declare @RecordAmount smallint
set @RecordAmount=(select count(*) from udot_TradeContractFreightQualityDetail)
if (@RecordAmount=0)
begin
set @Index=1
end
else
begin
set @Index=(select max(tcfqdf_Index) from udot_TradeContractFreightQualityDetail)+1
end
declare @TradeContractIndex smallint
set @TradeContractIndex=(select tcf_Index from udot_TradeContract where tcf_TradeContractNumber=@TradeContractNumber)
declare @FreightBreedIndex smallint
set @FreightBreedIndex=(select fbf_Index from udsdt_FreightBreed where fbf_Name=@FreightBreedName)
declare @InsertStatement nvarchar(4000)
set @InsertStatement='insert into udot_TradeContractFreightQualityDetail (tcfqdf_Index,
tcfqdf_TradeContractIndex,
tcfqdf_FreightBreedIndex,
tcfqdf_FreightBreedProductionArea,
tcfqdf_FreightBreedAmount,
tcfqdf_UnitPrice,
tcfqdf_DWFRL,
tcfqdf_HFF,
tcfqdf_HLL,
tcfqdf_SF,
tcfqdf_HZ) values ('+
convert(nvarchar(10),@Index)+','+
convert(nvarchar(10),@TradeContractIndex)+','+
convert(nvarchar(10),@FreightBreedIndex)+
','''+@FreightBreedProductionArea+''','+
convert(nvarchar(10),@FreightBreedAmount)+','+
convert(nvarchar(10),@UnitPrice)+','+
convert(nvarchar(10),@DWFRL)+','+
convert(nvarchar(10),@HFF)+','+
convert(nvarchar(10),@HLL)+','+
convert(nvarchar(10),@SF)+','+
convert(nvarchar(10),@HZ)+')'
-- select 1
if exists(select 1 from udot_TradeContractFreightQualityDetail where tcfqdf_TradeContractIndex=@TradeContractIndex and tcfqdf_FreightBreedIndex=@FreightBreedIndex)
raiserror('已存在同名记录',16,1)
else
execute(@InsertStatement)
end
go