CREATE proc [dbo].[Sys_Rebate_Equity]
AS
declare @fMemberID varchar(50)
declare @Rebate decimal(18,2)
BEGIN
begin try
Begin Transaction
DECLARE cursor1 CURSOR for
select fMemberID,sum(fNumber) as 'fNumber' from BP_Equity where fNumber>0 group by fMemberID
open cursor1
fetch next from cursor1 into @fMemberID,@Rebate
while @@FETCH_STATUS=0
begin
select 1
fetch next from cursor1 into @id
end
close cursor1
deallocate cursor1
select 888
Commit Transaction
End Try
Begin Catch
if @@trancount > 0 ROLLBACK TRANSACTION
Select 8888
End Catch
END
USE [SOFTINFORTMS]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[proc_ShouLiDan_Allocation]
@S_ChenYunFang nvarchar(30),
@S_ChengYunContacter nvarchar(30),
@result int=10 output,
@Message varchar(1000) output
AS
BEGIN
BEGIN TRY
BEGIN TRAN
DECLARE @r_id varchar(50)
DECLARE @r_ShouHuoRenOrg nvarchar(100)
DECLARE @r_Consignee varchar(50)
DECLARE My_Cursor CURSOR FOR SELECT S_ShouLiDanId,S_ShouHuoRenOrg,S_Consignee FROM BN_ShouLiDan WHERE S_ShouLiDanId IN(SELECT * FROM fun_Split(@S_ShouLiDanId,','))
OPEN My_Cursor
fetch next from My_Cursor into @r_id,@r_ShouHuoRenOrg,@r_Consignee
while @@fetch_status<>-1
begin
SET @result=1;
SET @Message='操作成功';
fetch next from My_Cursor into @r_id,@r_ShouHuoRenOrg,@r_Consignee
end
close My_Cursor
deallocate My_Cursor
COMMIT TRAN;
END TRY
BEGIN CATCH
SET @result = 0;
SET @Message = ERROR_MESSAGE();
IF @@TRANCOUNT > 0
ROLLBACK TRAN;
;THROW
END CATCH
END
C#接受result、Message
SqlParameter[] parameters ={
new SqlParameter("@result",SqlDbType.Int),
new SqlParameter("@Message",SqlDbType.VarChar,1000)
};
parameters[0].Direction = ParameterDirection.Output; //result 存储过程返回
parameters[1].Direction = ParameterDirection.Output; //Message 存储过程返回
//执行存储过程
parameters[0].Value;//获取result的值