ALTER PROCEDURE [dbo].[PR_Storeprocedure]( @parameters 1 @parammete 2.. ) AS BEGIN BEGIN TRY -------------- BEGIN TRY -------------- SET NOCOUNT ON; declare @paramter 3 declare @paramter 4 to 30 DECLARE @TRAN_ID INT Declare @TRAN_BAL Table(TRN_ID int) while(len(@paramter 3)>0) begin set @Param3=substring(condition)-- here i will get 1,2,4,3 values BEGIN TRANSACTION if not exists (condition @Param3 ) begin if(@Attendence is not null) begin if(@type='R') begin insert into table1 ( column 1 ) values(value 1) update dbo.table1 set cloum2=@prameter20 where condition ------------ACCOUNTS INTEGRATION------------------------------- INSERT INTO @TRAN_BAL EXEC [dbo].[PR_SP] @parameter=@param1 SELECT @TRAN_ID=MAX(TRN_ID) FROM @TRAN_BAL IF(@TRAN_ID=0 OR @TRAN_ID IS NULL) BEGIN RAISERROR ('NOT INSERTED IN ACCOUNTS',16,1) ROLLBACK TRANSACTION RETURN END ELSE BEGIN UPDATE dbo.Table2 SET TRAN_ID=@TRAN_ID ,MODIFIED_DATE=GETDATE()WHERE condition END ------------END-ACCOUNTS INTEGRATION--------- end end set @Param3=substring(condition)-- this will repeat the condition COMMIT TRANSACTION end END TRY -------------- END TRY -------------- ------------ CONDITION TO CHECK, EITHER TO "COMMIT" OR "ROLLBACK" TRANSACTION ------ BEGIN CATCH RAISERROR('ERROR IN TRANSACTION',16,1) rollback TRANSACTION SELECT ERROR_NUMBER() AS ERRORNUMBER ,ERROR_SEVERITY() AS ERRORSEVERITY ,ERROR_STATE() AS ERRORSTATE ,ERROR_PROCEDURE() AS ERRORPROCEDURE ,ERROR_LINE() AS ERRORLINE ,ERROR_MESSAGE() AS ERRORMESSAGE; END CATCH end
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)