IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_sys_calc_bizauthority_all]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_sys_calc_bizauthority_all]
GO
create procedure [dbo].[mps_sys_calc_bizauthority_all](
@cmpid int
)   
as  
begin  
   
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED 
  declare status1 cursor LOCAL FORWARD_ONLY READ_ONLY for  
  select biz_id     from mps_biztype   with(nolock) where  biz_cmpid=@cmpid 
  declare @bizid int 
  open status1  
  FETCH NEXT FROM status1 INTO @bizid 
  WHILE (@@FETCH_STATUS = 0)  
  BEGIN  
print '------'+convert(varchar(10),@bizid) +'------------' 
BEGIN TRY 
   BEGIN TRAN 
exec mps_sys_calc_bizauthority @cmpid ,@bizid 
COMMIT TRAN -------提交事务
END TRY-----------结束捕捉异常
BEGIN CATCH------------有异常被捕获
IF @@TRANCOUNT > 0---------------判断有没有事务
BEGIN
ROLLBACK TRAN----------回滚事务
END 
print ERROR_MESSAGE() 
END CATCH--------结束异常处理
FETCH NEXT FROM status1 INTO @bizid 
  END  
  CLOSE status1  
  DEALLOCATE status1   

end