------------------------------
create proc SaveFinancialProduct
@FinancialName nvarchar(50),--产品名称
@YieldRateName nvarchar(60),--对应变量名称,即收益率类别 (例如:年收益率12.00%)
@ProductType int, --产品类型
@ProductPeriod int, --产品期限
as
begin
declare @con int,@tranError int -- 定义变量
set @tranError=0;
set @con=(select COUNT(*) from FinancialProduct where FinancialName=@FinancialName);
if(@con=0)
begin
begin transaction
insert into FinancialProduct values (@FinancialName,@YieldRateName,@ProductType,@ProductPeriod);
set @tranError=@tranError + @@Error;
if(@tranError=0)
begin
commit transaction;
select 'OK';
end
else
begin
Rollback TransAction; --回滚
--select 'Error';
end
end
else
begin
select 'Error';
end
end