CREATE PROCEDURE Add_Transaction_AND_Post @cUserID CHAR(10) , @nSession INT, @nCreateTimeCode TINYINT, @nAutoAdjustDIffs TINYINT, @nReduceAmount INT AS SET NOCOUNT ON /** Created By : Shawn Dorion Created On : October 16, 2001 Description : This process will automatically adjust shift differentials, post transactions and insert transactions HD # 10404 Called From : TCENTRY Changes : N/A **/ --DECLARE -- @cUserID CHAR(10) , @nSession INT, @nCreateTimeCode TINYINT, @nAutoAdjustDIffs TINYINT, @nReduceAmount INT ----------------------------------------------------------------------- --------------DECLARE VARIABLES-------------------------------- ----------------------------------------------------------------------- --PRINT 'Declare Vars' -- Vars for Procssing transactions DECLARE @PROC_Batchnum CHAR(10), @PROC_txnum CHAR(10), @PROC_period CHAR(2), @PROC_empnum CHAR(10), @PROC_tcnum CHAR(2), @PROC_pcode TINYINT, @PROC_wtime INT, @PROC_etime INT, @PROC_Old_Etime INT, @PROC_Old_Tcnum CHAR(2), @Proc_Old_pcode TINYINT, @PROC_Old_period CHAR(2), @Proc_Txdate CHAR(10), @Proc_Old_Txdate CHAR(10) -- Vars for the diff processing DECLARE @cDiff_Txnum CHAR(10), @cDiff_Empnum CHAR(10), @cDiff_Tcnum CHAR(2), @iDiff_Etime INT, @iDiff_Old_Etime INT, @iDiff_Pcode TINYINT, @cDiff_Period CHAR(2), @cDiff_Txdate CHAR(10) -- Vars for loop to build sql and flags DECLARE @Update CHAR(6000), @Update_Batch INT, @Error INT, @NEW_Txnum CHAR(10), @FinalPeriod CHAR(4), @cUsernum CHAR(10), @cUserName CHAR(30), @cNewMod_Log VARCHAR(600), @iCount INT, @cMessage1 VARCHAR(200), @cMessage2 VARCHAR(200), @bPointerValue VARBINARY(16), @cYearEndDate CHAR(10) ----------------------------------------------------------------------- --------------END DECLARE VARIABLES-------------------------- ----------------------------------------------------------------------- ----------------------------------------------------------------------- --------------DEFINE VARIABLE VALUES------------------------- ----------------------------------------------------------------------- --PRINT 'Define Vars' --Used in the process loop SET @Update_Batch = 0 SET @Error = 0 SET @NEW_Txnum = '' SET @cUsernum = @cUserId SET @cNewMod_Log = '' SELECT @cUserName = RTRIM(lname) + ',' + RTRIM(fname) FROM users WHERE userid = @cUserId SELECT @cYearEndDate = Xdate2 FROM control ----------------------------------------------------------------------- --------------END DEFINE VARIABLE VALUES------------------- ----------------------------------------------------------------------- ----------------------------------------------------------------------- --------------DECLARE CURSORS----------------------------------- ----------------------------------------------------------------------- --PRINT 'DECLARE Cursors -- Tctxy1_Diff' DECLARE Tctxy1_Diff CURSOR FOR SELECT tx.txnum, tx.empnum, tx.tcnum, tx.etime, tx.pcode, SUBSTRING(tx.txdate,6,2), tx.Txdate FROM tctxy1 tx, timename t WHERE empnum in (SELECT empnum FROM tx_Add_Edit WHERE userid = @cUserid AND session_id = @nSession) AND txdate in (SELECT txdate FROM tx_Add_Edit WHERE userid = @cUserid AND session_id = @nSession) AND tcnum = t.code AND t.banktype IN (5) SET @ERROR = @@ERROR IF @ERROR <> 0 BEGIN SELECT -1 AS 'Status', 'Differential Cursor Declaration Failed' as 'Error_Text' RETURN END --@ERROR <> 0 --PRINT 'DECLARE Cursors -- Process Records' DECLARE Process_Records CURSOR FOR SELECT batchnum,txnum, SUBSTRING( txdate,6,2) AS 'period', empnum, tcnum, pcode, wtime, etime, old_etime, old_tcnum, old_pcode, SUBSTRING( old_date,6,2) AS 'old_period', txdate, old_date FROM TX_Add_Edit WHERE userid = @cUserid AND session_id = @nSession SET @ERROR = @@ERROR IF @ERROR <> 0 BEGIN DEALLOCATE Tctxy1_Diff SELECT -1 AS 'Status', 'Process Cursor Declaration Failed' as 'Error_Text' RETURN END --@ERROR <> 0 ----------------------------------------------------------------------- --------------END CURSOR DECLARATION----------------------- ----------------------------------------------------------------------- -- test to see if we have any records to process SELECT @iCount = COUNT ( txnum ) FROM tx_add_Edit WHERE userid = @cUserid AND session_id = @nSession -- test for any sql errors SET @ERROR = @@ERROR IF @ERROR <> 0 BEGIN DEALLOCATE Tctxy1_Diff DEALLOCATE Process_Records SELECT -1 AS 'Status', 'Selection for time sheet totals failed.' as 'Error_Text' RETURN END --@ERROR <> 0 -- test to see if we have any records to process IF @iCount = 0 BEGIN DEALLOCATE Tctxy1_Diff DEALLOCATE Process_Records SELECT -1 AS 'Status', 'There were no records to added to the server.' as 'Error_Text' RETURN END --IF @iCount = 0 -- test to see if the records we added to the server is in sequence with the current server records --if the record is not then we must return back to the user data has changed SET @iCount = 0 SELECT @iCount = COUNT(tx.txnum) FROM tctxy1 tx, tx_add_edit ae WHERE tx.txnum = ae.txnum AND userid = @cUserid AND session_id = @nSession AND tx.etime <> ae.old_etime -- test for any sql errors SET @ERROR = @@ERROR IF @ERROR <> 0 BEGIN DEALLOCATE Tctxy1_Diff DEALLOCATE Process_Records SELECT -1 AS 'Status', 'Selection for time sheet totals failed.' as 'Error_Text' RETURN END --@ERROR <> 0 -- we have a count greater than 0 that means the data has been changed by another user IF @iCount > 0 BEGIN DEALLOCATE Tctxy1_Diff DEALLOCATE Process_Records SELECT -2 AS 'Status', 'Data Has Changed Please requery the sever for the changes to be displayed.' as 'Error_Text' -- Return the new recods or edited records back to the front end to update there data SELECT tx.* FROM tctxy1 tx , tx_Add_Edit ae WHERE tx.txnum = ae.txnum and ae.userid = @cUserid AND ae.session_id = @nSession RETURN END --IF @iCount = 0 --PRINT 'Getting Distinct Records' -- get all distinct records so we can build the tstoty file if we need the values SELECT DISTINCT empnum, tcnum INTO #Add_Tstoty FROM Tx_Add_Edit WHERE userid = @cUserid AND session_id = @nSession AND txdate <= @cYearEndDate SET @ERROR = @@ERROR IF @ERROR <> 0 BEGIN DEALLOCATE Tctxy1_Diff DEALLOCATE Process_Records SELECT -1 AS 'Status', 'Selection for time sheet totals failed.' as 'Error_Text' RETURN END --@ERROR <> 0 --------------------------------------------------------------------------------------- ------------------Processing Starts Here - BEGIN TRANSACTION---------------- --------------------------------------------------------------------------------------- --PRINT 'BEGIN TRANSACTION' BEGIN TRANSACTION -- create new time codes for this user as this person does not have any codes IF @nCreateTimeCode = 1 BEGIN --PRINT 'Creating Time Code and Employee Combination' --PRINT 'Adding To Tstoty1' INSERT INTO TSTOTY1 (empnum,tcnum) SELECT empnum,tcnum FROM #Add_Tstoty SET @ERROR = @@ERROR IF @ERROR <> 0 BEGIN --PRINT '---> ROLL BACK - Tstoty1' ROLLBACK DEALLOCATE Tctxy1_Diff DEALLOCATE Process_Records SELECT -1 AS 'Status', 'Failed to create Time Sheet Totals Year 1' as 'Error_Text' RETURN END --@ERROR <> 0 --PRINT 'Adding To Tstoty2' INSERT INTO TSTOTY2 (empnum,tcnum) SELECT empnum,tcnum FROM #Add_Tstoty SET @ERROR = @@ERROR IF @ERROR <> 0 BEGIN --PRINT '---> ROLL BACK - Tstoty2' ROLLBACK DEALLOCATE Tctxy1_Diff DEALLOCATE Process_Records SELECT -1 AS 'Status', 'Failed to create Time Sheets Totals Year 2' as 'Error_Text' RETURN END --@ERROR <> 0 --PRINT 'Adding To Tstoty3' INSERT INTO TSTOTY3 (empnum,tcnum) SELECT empnum,tcnum FROM #Add_Tstoty SET @ERROR = @@ERROR IF @ERROR <> 0 BEGIN --PRINT '---> ROLL BACK - Tstoty3' ROLLBACK DEALLOCATE Tctxy1_Diff DEALLOCATE Process_Records SELECT -1 AS 'Status', 'Failed to create Time Sheets Totals Year 3' as 'Error_Text' RETURN END --@ERROR <> 0 DROP TABLE #Add_Tstoty END --IF @nCreateTimeCode = 1 ------------------------------------- --PRINT 'Opening Cursor - Process Records' OPEN Process_Records --PRINT '1st Fetch - Process Records' -- Perform the first fetch. FETCH NEXT FROM Process_Records INTO @Proc_Batchnum,@PROC_txnum, @PROC_Period, @PROC_empnum, @PROC_tcnum, @PROC_pcode, @PROC_wtime, @PROC_etime, @PROC_Old_Etime, @PROC_Old_Tcnum, @Proc_Old_pcode, @PROC_Old_Period, @PROC_Txdate, @PROC_Old_Txdate -- Check @@FETCH_STATUS to see if there are any more rows to fetch. WHILE @@FETCH_STATUS = 0 BEGIN -- if we are editing a record then perform the reversal IF LEN(@Proc_Old_Tcnum) > 0 AND @Proc_Old_Txdate <= @cYearEndDate BEGIN --PRINT 'Reversing - Process Records' SET @FinalPeriod = 'p' + RTRIM ( CAST ( @Proc_Old_Period AS CHAR)) + RTRIM ( CAST ( @Proc_Old_Pcode AS CHAR ) ) SET @Update = 'UPDATE tstoty1 SET ' + @FinalPeriod + ' = ' + @FinalPeriod + ' + ' + RTRIM(LTRIM(CAST((@Proc_Old_Etime * -1) AS CHAR))) + ' WHERE empnum = ''' + @Proc_Empnum + ''' AND tcnum = ''' + @Proc_Old_Tcnum + '''' --PRINT @Update EXEC (@Update) SET @ERROR = @@ERROR IF @ERROR <> 0 BEGIN --- Get out of the loop the variable is set so all we --- have to do is test the value at the end of the loop --PRINT '---> BREAK - Reversing Tx' BREAK END --IF @ERROR <> 0 -- Update the counter to show that we are editing -- versus adding because 0 + -1 = -1 + 1 = 0 -- basically nulls itself out SET @Update_Batch = @Update_Batch - 1 END --IF LEN(@Proc_Old_Tcnum) > 0 IF @Proc_Txdate <= @cYearEndDate BEGIN --PRINT 'Posting - Process Records' -- this is done for an add and edit SET @FinalPeriod = 'p' + RTRIM ( CAST ( @Proc_Period AS CHAR)) + RTRIM ( CAST ( @Proc_Pcode AS CHAR ) ) SET @Update = 'UPDATE tstoty1 SET ' + @FinalPeriod + ' = ' + @FinalPeriod + ' + ' + RTRIM(LTRIM(CAST(@Proc_Etime AS CHAR))) + ' WHERE empnum = ''' + @Proc_Empnum + ''' AND tcnum = ''' + @Proc_Tcnum + '''' --PRINT @Update EXEC (@Update) SET @ERROR = @@ERROR IF @ERROR <> 0 BEGIN --- Get out of the loop the variable is set so all we --- have to do is test the value at the end of the loop --PRINT '---> BREAK - Posting Tx' BREAK END --IF @ERROR <> 0 END --IF @Proc_Txdate <= @cYearEndDate -- Update the record update counter this value will be = 0 or greater than or equal to one SET @Update_Batch = @Update_Batch + 1 --PRINT 'Update Batch Value ' --PRINT @Update_Batch IF @Update_Batch > 0 BEGIN --PRINT 'Updating Batches' UPDATE batches SET txcount = txcount + 1 WHERE batchnum = @Proc_Batchnum SET @ERROR = @@ERROR IF @ERROR <> 0 BEGIN --PRINT '---> BREAK - Updating Batches' BREAK END --@ERROR <> 0 --PRINT 'Updating Control' -- Update the control control counter UPDATE Control SET txnum = txnum + 1 SET @ERROR = @@ERROR IF @ERROR <> 0 BEGIN --PRINT '---> BREAK - Updating Control' BREAK END --@ERROR <> 0 SELECT @NEW_Txnum = RTRIM ( LTRIM ( CAST ( txnum AS CHAR ) ) ) FROM CONTROL --PRINT @New_Txnum SET @ERROR = @@ERROR IF @ERROR <> 0 BEGIN --PRINT '---> BREAK - Getting New Tx Number' BREAK END --@ERROR <> 0 -- Set the Value for the new transaction including the padding SET @New_Txnum = REPLICATE ( '0',10 - LEN ( @New_Txnum ) ) + @New_Txnum --PRINT 'FORMATED Txnum : ' + @New_Txnum UPDATE Tx_Add_Edit SET txnum = @New_Txnum WHERE Txnum = @PROC_txnum AND userid = @cUserid AND session_id = @nSession SET @ERROR = @@ERROR IF @ERROR <> 0 BEGIN --- Get out of the loop the variable is set so all we --- have to do is test the value at the end of the loop --PRINT '---> BREAK - Updating Tx_Add_Edit Tx Number' BREAK END --IF @ERROR <> 0 --PRINT 'Inserting Transaction' INSERT INTO tctxy1 (batchnum, txnum, txdate, empnum, tcnum, schdnum, schdday, division, deptnum, assgnum, level4, level5, clasnum, pcode, rop, mamt, wtime, etime, notes, mod_log, perrate, symb, rank) SELECT batchnum, txnum, txdate, empnum, tcnum, schdnum, schdday, division, deptnum, assgnum, level4, level5, clasnum, pcode, rop, mamt, wtime, etime, notes, mod_log, perrate, symb, rank FROM Tx_Add_Edit WHERE TXNUM = @New_Txnum AND userid = @cUserid AND session_id = @nSession SET @ERROR = @@ERROR IF @ERROR <> 0 BEGIN --- Get out of the loop the variable is set so all we --- have to do is test the value at the end of the loop --PRINT '---> BREAK - Inserting Tx' BREAK END --IF @ERROR <> 0 END ELSE -- Editing BEGIN --PRINT deleteting Original entry -- delete the original entry and then add the new one with the new information DELETE FROM tctxy1 WHERE txnum = @Proc_Txnum --PRINT 'Inserting Transaction' INSERT INTO tctxy1 (batchnum, txnum, txdate, empnum, tcnum, schdnum, schdday, division, deptnum, assgnum, level4, level5, clasnum, pcode, rop, mamt, wtime, etime, notes, mod_log, perrate, symb, rank) SELECT batchnum, txnum, txdate, empnum, tcnum, schdnum, schdday, division, deptnum, assgnum, level4, level5, clasnum, pcode, rop, mamt, wtime, etime, notes, mod_log, perrate, symb, rank FROM Tx_Add_Edit WHERE TXNUM = @Proc_Txnum AND userid = @cUserid AND session_id = @nSession SET @ERROR = @@ERROR IF @ERROR <> 0 BEGIN --- Get out of the loop the variable is set so all we --- have to do is test the value at the end of the loop --PRINT '---> BREAK - Inserting Tx' BREAK END --IF @ERROR <> 0 END --IF @Update_Batch <> -1 --PRINT 'Fetch - Process Records' -- This is executed as long as the previous fetch succeeds. FETCH NEXT FROM Process_Records INTO @Proc_Batchnum,@PROC_txnum, @PROC_Period, @PROC_empnum, @PROC_tcnum, @PROC_pcode, @PROC_wtime, @PROC_etime, @PROC_Old_Etime, @PROC_Old_Tcnum, @Proc_Old_pcode, @PROC_Old_Period, @PROC_Txdate, @PROC_Old_Txdate END -- discard the cursor as it is not needed any more CLOSE Process_Records DEALLOCATE Process_Records -- Test for any loop errors - break will kick us out of the loop - the error variabnle will be set at this point IF @ERROR <> 0 BEGIN ROLLBACK DEALLOCATE Tctxy1_Diff SELECT -1 AS 'Status', 'Failed Processing Record(s).' as 'Error_Text' RETURN END -- If auto adjust diffs then process a lopp tha will reduce all diffs for this date IF @nAutoAdjustDiffs = 1 -- Process the Differentials for the user BEGIN --PRINT 'IN Auto Adjust Diffs' --PRINT 'Open Cursor Tctxy1_Diff' -- Cursor Created Above OPEN Tctxy1_Diff --PRINT 'Get First Row - Tctxy1 Diff' -- Perform the first fetch. FETCH NEXT FROM Tctxy1_Diff INTO @cDiff_Txnum, @cDiff_Empnum, @cDiff_Tcnum, @iDiff_Etime, @iDiff_Pcode, @cDiff_Period, @cDiff_Txdate -- Check @@FETCH_STATUS to see if there are any more rows to fetch. -- OR we don't have any timeto reduce WHILE @@FETCH_STATUS = 0 AND @nReduceAmount <> 0 BEGIN --PRINT 'Inside Diff Loop' -- this value must be stored as this is the only to reverse -- the value and then re update it with the new value SET @iDiff_Old_Etime = @iDiff_Etime -- is the diff time greater than the time to reduce it --by if so use all of the time and then set the reduce value to zero IF @iDiff_Etime > @nReduceAmount BEGIN --PRINT 'Reducing Etime = nReduceAmount - Set nReduceAmount = 0' -- set the values for the insert and set the Reduce amount to -- 0 to exit out as we have ful filled the loop requirements SET @iDiff_Etime = @iDiff_Etime - @nReduceAmount SET @nReduceAmount = 0 END ELSE BEGIN --PRINT 'Reduce nReduceAmount by Etime - Set Diff Etime = 0' SET @nReduceAmount = @nReduceAmount - @iDiff_Etime SET @iDiff_Etime = 0 END ---------------- -- Update records here - perform reversal and posting ---------------- IF @cDiff_Txdate <= @cYearEndDate BEGIN --PRINT 'Reverse the Original Diff Etime' SET @FinalPeriod = 'p' + RTRIM ( CAST ( @cDiff_Period AS CHAR)) + RTRIM ( CAST ( @iDiff_Pcode AS CHAR ) ) SET @Update = 'UPDATE tstoty1 SET ' + @FinalPeriod + ' = ' + @FinalPeriod + ' + ' + RTRIM ( LTRIM ( CAST ( ( @iDiff_Old_Etime * -1) AS CHAR ) ) ) + ' WHERE empnum = ''' + @cDiff_Empnum + ''' AND tcnum = ''' + @cDiff_tcnum + '''' SET @cMessage1 = 'Auto-Adjust Differentials - Original Differential Value : ' + RTRIM ( LTRIM ( CAST ( ( @iDiff_Old_Etime ) AS CHAR ) ) ) --PRINT @Update EXEC (@Update) SET @ERROR = @@ERROR IF @ERROR <> 0 BEGIN --- Get out of the loop the variable is set so all we --- have to do is test the value at the end of the loop --PRINT '---> BREAK - Reversing Diff Etime' BREAK END --IF @ERROR <> 0 --PRINT 'Post the New Diff Etime' SET @FinalPeriod = 'p' + RTRIM ( CAST ( @cDiff_Period AS CHAR)) + RTRIM ( CAST ( @iDiff_Pcode AS CHAR ) ) SET @Update = 'UPDATE tstoty1 SET ' + @FinalPeriod + ' = ' + @FinalPeriod + ' + ' + RTRIM ( LTRIM ( CAST ( @iDiff_Etime AS CHAR ) ) ) + ' WHERE empnum = ''' + @cDiff_Empnum + ''' AND tcnum = ''' + @cDiff_tcnum + '''' SET @cMessage2 = 'Auto-Adjust Differentials - Adjusted Differential Value : ' + RTRIM ( LTRIM ( CAST ( @iDiff_Etime AS CHAR ) ) ) --PRINT @Update EXEC (@Update) SET @ERROR = @@ERROR IF @ERROR <> 0 BEGIN --- Get out of the loop the variable is set so all we --- have to do is test the value at the end of the loop --PRINT '---> BREAK - Posting Diff Time' BREAK END --IF @ERROR <> 0 END -- IF @cDiff_Txdate <= @cYearEndDate -- update the transaction as well UPDATE tctxy1 SET etime = @iDiff_Etime, wtime = @iDiff_Etime WHERE txnum = @cDiff_Txnum --**************************************************************************** -- Edit - We have to update the modification log -- Add to the mod log field the delete information. Adding to a text field in SQL Server is more difficult then it needs to be. -- Get the pointer value of the text field SELECT @bPointervalue = TEXTPTR(mod_log) FROM tctxy1 WHERE txnum = @cDiff_txnum -- Update the text field SET @cNewMod_Log = RTRIM('Modified by : ' + @cUsernum + ' ' + @cUserName + CHAR(13) + CHAR(10) + 'Date and Time : ' + RTRIM(CAST(DATEPART(yyyy, GETDATE()) AS CHAR)) + '/' + RTRIM(CAST(DATEPART(mm, GETDATE()) AS CHAR)) + '/' + RTRIM(CAST(DATEPART(dd, GETDATE()) AS CHAR)) + ' ' + CAST(DATEPART(hh, GETDATE()) AS CHAR)) + ':' + REPLICATE('0', 2 - LEN(RTRIM(CAST(DATEPART(mi, GETDATE()) AS CHAR)))) + RTRIM(CAST(DATEPART(mi, GETDATE()) AS CHAR)) + ':' + RTRIM(CAST(DATEPART(ss, GETDATE()) AS CHAR)) + CHAR(13) + CHAR(13) + @cMessage1 + CHAR(13) + @cMessage2 + CHAR(13) + CHAR(13) --PRINT @cNewMod_Log IF @bPointervalue IS NOT NULL UPDATETEXT tctxy1.mod_log @bPointervalue 0 0 @cNewMod_Log --**************************************************************************** --PRINT 'GET Next Diff Record' -- This is executed as long as the previous fetch succeeds. FETCH NEXT FROM Tctxy1_Diff INTO @cDiff_Txnum, @cDiff_Empnum, @cDiff_Tcnum, @iDiff_Etime, @iDiff_Pcode, @cDiff_Period END --@@FETCH_STATUS = 0 OR @nReduceAmount = 0 -- discard the cursor as it is not needed any more CLOSE Tctxy1_Diff END -- IF @nAutoAdjustDiffs = 1 DEALLOCATE Tctxy1_Diff --PRINT 'Test For Commit' IF @ERROR = 0 BEGIN --PRINT '---> Commiting Transaction' COMMIT TRANSACTION SELECT 1 AS 'Status', 'Record(s) Saved and Updated' as 'Error_Text' END ELSE BEGIN --PRINT '---> ROLL BACK Transaction' ROLLBACK SELECT -1 AS 'Status', 'Record(s) were not updated and saved.' as 'Error_Text' RETURN END --------------------------------------------------------------------------------------- ------------------Processing Ends Here - COMMIT TRANSACTION--------------- --------------------------------------------------------------------------------------- -- Return the new recods or edited records back to the front end to update there data SELECT tx.* FROM tctxy1 tx WHERE tx.txnum IN (SELECT txnum from tx_add_edit where userid = @cUserid AND session_id = @nSession) -- if auto adjust is set to manual - then return the -- records back to the user to record them. IF @nAutoAdjustDiffs = 0 BEGIN --PRINT 'Selecting Diffs For User to Manually Adjust' -- return the diffs if we do not auto process SELECT tx.txnum, tx.txdate, tx.etime,tx.tcnum FROM Tctxy1 tx WHERE tx.empnum IN (select distinct empnum from tx_add_Edit WHERE userid = @cUserid AND session_id = @nSession) AND tx.txdate IN (select distinct txdate from tx_add_Edit WHERE userid = @cUserid AND session_id = @nSession) AND tx.txnum NOT IN (select distinct txnum from tx_add_Edit WHERE userid = @cUserid AND session_id = @nSession) AND tx.tcnum IN (SELECT CODE from timename where banktype = 5) END -- delete the transaction records now that we are done woth them DELETE FROM TX_Add_Edit WHERE userid = @cUserid AND session_id = @nSession SET @ERROR = @@ERROR IF @ERROR <> 0 BEGIN --PRINT '---> Deleting Tx_Add_Edit records for this session' SELECT -1 AS 'Status', 'Failed to delete the Server transaction temp record' as 'Error_Text' RETURN END --@ERROR <> 0 SET NOCOUNT OFF