Result Processing 02-07-2012

USE [dbAsaTest]
GO
/****** Object: StoredProcedure [dbo].[sp_ResultProcessing] Script Date: 07/02/2012 17:45:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author: Update by: Md. Nazim Uddin>
-- alter date: <Date: 14-11-2011>
-- Description: <Process Results of Selected Term>
-- =============================================
ALTER PROCEDURE [dbo].[sp_ResultProcessing]
(
@TermId varchar(50)
)
--exec sp_ResultProcessing 'CSE2012JAN_2K12Y1T1'
AS
BEGIN
-- Declare Variables for internal use
DECLARE
@intErrorCode int,
@CourseId varchar(20),
@TotalMarks Decimal(10,2),
@StudentId int,
@LetterGrade varchar(5),
@GradePoint Decimal(6, 2),
@RegularTerm varchar(30),
@TermType char,
@Count int,
@ProcessingDecision int
SELECT @ProcessingDecision=(SELECT TermClosingStatus FROM T_Term_Setup WHERE TermId=@TermId)
IF(@ProcessingDecision=0)
--------------------------------------------------------------------------------------------------------------------
BEGIN
---------------------------------------------------------------------------------------------------------------------
---- Starting Transaction---------
begin transaction
------------------------------------------------ Term Closing -----------------------------------------------------
------- Makeing Term Closed --------
---15-11-2011
UPDATE T_Term_Setup
SET TermClosingStatus=1
WHERE TermId=@TermId
-- If Any errors then go for Roll Back Transaction
SELECT @intErrorCode = @@ERROR
IF (@intErrorCode <> 0) GOTO PROBLEMERROR
----------------------------------------------- Class Test Marks Update --------------------------------------------------
--------Update Class Test Marks
------declare TermResultCursor cursor for
------select distinct CourseId
------from T_Term_Class_Test_Marks
------where TermId = @TermId
------open TermResultCursor
------fetch next from TermResultCursor into
------@CourseId
------while @@FETCH_STATUS = 0
------begin
------ declare ClassTestResult cursor for
------ SELECT StudentId, SUM(ClassTestMarks)
------ FROM T_Term_Class_Test_Marks
------ WHERE CourseId = @CourseId AND TermId = @TermId
------ GROUP BY StudentId
------ open ClassTestResult
------ fetch next from ClassTestResult into
------ @StudentId, @TotalMarks
------ while @@FETCH_STATUS = 0
------ begin
------ UPDATE T_Term_Std_Result_Theory_Details
------ SET ClassTest=@TotalMarks
------ WHERE StudentId=@StudentId AND CourseId=@CourseId AND TermId = @TermId
------ fetch next from ClassTestResult into
------ @StudentId, @TotalMarks
------ end
------ close ClassTestResult
------ deallocate ClassTestResult
------ fetch next from TermResultCursor into
------ @CourseId
------end
------close TermResultCursor
------deallocate TermResultCursor
-------- If Any errors then go for Roll Back Transaction
------SELECT @intErrorCode = @@ERROR
------IF (@intErrorCode <> 0) GOTO PROBLEMERROR
--modified in 26/01/2012
-------------------------------------------- Theory Related --------------------------------------------------------
--Read RegularTerm
SELECT @TermType=TermType, @RegularTerm=isnull(RegularTermId,@TermId)
FROM T_Term_Setup
WHERE TermId=@TermId
--Read TotalMarks of Theory
SELECT @TotalMarks=TotalMarks
FROM T_Term_Marks_Distribution
WHERE TermId=@TermId AND CourseType='Theory'
--Update %Marks of Theory 26/01/2012 modification
UPDATE T_Term_Std_Result_Theory_Details
SET [%Marks]=(ISNULL(Attendance,0)+ISNULL(ScrutinizeA,0)+ISNULL(ScrutinizeB,0)+ISNULL(ClassTest,0)+ISNULL(Grace,0))*100/@TotalMarks
WHERE TermId=@TermId
-- If Any errors then go for Roll Back Transaction
SELECT @intErrorCode = @@ERROR
IF (@intErrorCode <> 0) GOTO PROBLEMERROR
--modified in 26/01/2012
-------------------------------------------- Sessional Related --------------------------------------------------------
--Read TotalMarks of Sessional
SELECT @TotalMarks=TotalMarks
FROM T_Term_Marks_Distribution
WHERE TermId=@TermId AND CourseType='Sessional'
--Update %Marks of Sessional 26/01/2012 modification
UPDATE T_Term_Student_Result_Lab_Details
SET [%Marks]=(ISNULL(LabPerformance,0)+ISNULL(Attendance,0)+ISNULL(QuizViva,0)+ISNULL(CenteralViva,0)+ISNULL(Grace,0))*100/@TotalMarks
WHERE TermId=@TermId
-- If Any errors then go for Roll Back Transaction
SELECT @intErrorCode = @@ERROR
IF (@intErrorCode <> 0) GOTO PROBLEMERROR
-------------------------------------------- Thesis Related --------------------------------------------------------
--Read TotalMarks of Sessional
--SELECT @TotalMarks=TotalMarks
-- FROM T_Term_Marks_Distribution
-- WHERE TermId=@TermId AND CourseType='Thesis'
--DECLARE @TotalMarks INT,
--@TermId varchar(50)
--SELECT @TermId='CSE2011NOV_2K10Y4T1'
SELECT @TotalMarks=100
--Update PercentMarks of Sessional
UPDATE T_Term_Std_ThesisProject_Result_Details
SET PercentMarks=([4thYear1stTerm]+[VivaVoce]+[InternalExaminer]+[ExternalExaminer])*100/@TotalMarks,
TotalMarks=([4thYear1stTerm]+[VivaVoce]+[InternalExaminer]+[ExternalExaminer]),
CourseContinuityStatus='X'
WHERE TermId=@TermId
-- If Any errors then go for Roll Back Transaction
SELECT @intErrorCode = @@ERROR
IF (@intErrorCode <> 0) GOTO PROBLEMERROR
--26/01/2012 modified
---------------------------------------------- Theory Result Processing ---------------------------------------------------
--Student's Theory result with Letter grade
declare TermTheoryResultCursor cursor for
select isnull(CourseId,''),
isnull(StudentId,-1),
isnull(CEILING([%Marks]),-1)
from T_Term_Std_Result_Theory_Details
where TermId = @TermId
open TermTheoryResultCursor
fetch next from TermTheoryResultCursor into
@CourseId, @StudentId, @TotalMarks
while @@FETCH_STATUS = 0
begin
SELECT @LetterGrade=LetterGrade, @GradePoint=GPA
FROM T_Term_Marks_GPA_Setup
WHERE StartMarks<=@TotalMarks AND @TotalMarks<=EndMarks AND TermId=@TermId
--Insert into Term_Wise_Course_Result
--INSERT INTO T_Term_Wise_Course_Result(TermId, RegularTerm, CourseId, StudentId, LetterGrade, GradePoint, TermType)
-- VALUES(@TermId, @RegularTerm, @CourseId, @StudentId, @LetterGrade, @GradePoint,@TermType)
--Insert into T_Common_Student_Earned_Credit
--if(@LetterGrade<>'F')
--begin
--INSERT INTO T_Common_Student_Earned_Credit(TermId, RegularTerm, CourseId, StudentId, LetterGrade, GradePoint,TermType)
-- VALUES(@TermId, @RegularTerm, @CourseId, @StudentId, @LetterGrade, @GradePoint,@TermType)
--end
UPDATE T_Term_Std_Result_Theory_Details
SET LetterGrade= @LetterGrade, GradePoint=@GradePoint
WHERE TermId=@TermId AND StudentId=@StudentId AND CourseId=@CourseId
--If Failed insert or update Common_Backlog_Info
IF(@GradePoint=0)
begin
SELECT @Count=COUNT(*)
FROM T_Common_Backlog_Info
WHERE StudentId=@StudentId AND CourseId=@CourseId
IF(@Count=0)
begin
INSERT T_Common_Backlog_Info(StudentId, TermId, CourseId)
VALUES(@StudentId, @TermId, @CourseId)
end
ELSE
begin -- N= Not registrated, Y=Registrated, B=again backlog
UPDATE T_Common_Backlog_Info SET RegistrationStatus='B' WHERE StudentId=@StudentId AND CourseId=@CourseId
end
print @Count
print 'Separate'
end
--Delete Course From BackLog If passed.......
IF(@GradePoint>0)
begin
DELETE FROM T_Common_Backlog_Info
WHERE StudentId=@StudentId AND CourseId=@CourseId
end
-- If Any errors then go for Roll Back Transaction
SELECT @intErrorCode = @@ERROR
IF (@intErrorCode <> 0) GOTO PROBLEMERROR
fetch next from TermTheoryResultCursor into
@CourseId, @StudentId, @TotalMarks
end
close TermTheoryResultCursor
deallocate TermTheoryResultCursor
-- If Any errors then go for Roll Back Transaction
SELECT @intErrorCode = @@ERROR
IF (@intErrorCode <> 0) GOTO PROBLEMERROR
-- 26/01/2012 modification
---------------------------------------------- Sessional Result Processing -----------------------------------------------------------
--Student's Sessional result with Letter grade
declare TermSessionalResultCursor cursor for
select isnull(CourseId,''),
isnull(StudentId,-1),
isnull(CEILING([%Marks]),-1)
from T_Term_Student_Result_Lab_Details
where TermId = @TermId
open TermSessionalResultCursor
fetch next from TermSessionalResultCursor into
@CourseId, @StudentId, @TotalMarks
while @@FETCH_STATUS = 0
begin
SELECT @LetterGrade=LetterGrade, @GradePoint=GPA
FROM T_Term_Marks_GPA_Setup
WHERE StartMarks<=@TotalMarks AND @TotalMarks<=EndMarks AND TermId=@TermId
--Insert into Term_Wise_Course_Result
---TermType added 22-11-2011
--INSERT INTO T_Term_Wise_Course_Result(TermId, RegularTerm, CourseId, StudentId, LetterGrade, GradePoint, TermType)
-- VALUES(@TermId, @RegularTerm, @CourseId, @StudentId, @LetterGrade, @GradePoint, @TermType)
--Insert into T_Common_Student_Earned_Credit
--if(@LetterGrade<>'F')
--begin
--INSERT INTO T_Common_Student_Earned_Credit(TermId, RegularTerm, CourseId, StudentId, LetterGrade, GradePoint,TermType)
-- VALUES(@TermId, @RegularTerm, @CourseId, @StudentId, @LetterGrade, @GradePoint,@TermType)
--end
UPDATE T_Term_Student_Result_Lab_Details
SET LetterGrade= @LetterGrade, GradePoint=@GradePoint
WHERE TermId=@TermId AND StudentId=@StudentId AND CourseId=@CourseId
--If Failed insert or update Common_Backlog_Info
IF(@GradePoint=0)
begin
SELECT @Count=COUNT(*)
FROM T_Common_Backlog_Info
WHERE StudentId=@StudentId AND CourseId=@CourseId
IF(@Count=0)
begin
INSERT T_Common_Backlog_Info(StudentId,TermId, CourseId)
VALUES(@StudentId, @TermId, @CourseId)
end
ELSE
begin
UPDATE T_Common_Backlog_Info SET RegistrationStatus='B' WHERE StudentId=@StudentId AND CourseId=@CourseId
end
print @Count
print 'Separate'
end
--Delete Course From BackLog If passed.......
IF(@GradePoint>0)
begin
DELETE FROM T_Common_Backlog_Info
WHERE StudentId=@StudentId AND CourseId=@CourseId
end
-- If Any errors then go for Roll Back Transaction
SELECT @intErrorCode = @@ERROR
IF (@intErrorCode <> 0) GOTO PROBLEMERROR
fetch next from TermSessionalResultCursor into
@CourseId, @StudentId, @TotalMarks
end
close TermSessionalResultCursor
deallocate TermSessionalResultCursor
-- If Any errors then go for Roll Back Transaction
SELECT @intErrorCode = @@ERROR
IF (@intErrorCode <> 0) GOTO PROBLEMERROR
--26/01/2012 modification
---------------------------------------- Thesis Result Processing --------------------------------------------------
--Student's Thesis result with Letter grade
DECLARE @ThesisProcessDecision INT,
@TargetYear INT,
@TargetTerm INT
SELECT @ThesisProcessDecision = COUNT(*) FROM T_Term_Std_ThesisProject_Result_Details
WHERE TermId = @TermId
SELECT @TargetYear=TargetYear,@TargetTerm=TargetTerm FROM T_Term_Setup WHERE TermId=@TermId
if(@ThesisProcessDecision>0 AND @TargetYear=4)
begin
declare TermThesisResultCursor cursor for
select isnull(CourseId,''),
isnull(StudentId,-1),
isnull(CEILING(PercentMarks),-1)
from T_Term_Std_ThesisProject_Result_Details
where TermId = @TermId
open TermThesisResultCursor
fetch next from TermThesisResultCursor into
@CourseId, @StudentId, @TotalMarks
while @@FETCH_STATUS = 0
begin
if(@TargetTerm=2)
begin
SELECT @LetterGrade=LetterGrade, @GradePoint=GPA
FROM T_Term_Marks_GPA_Setup
WHERE StartMarks<=@TotalMarks AND @TotalMarks<=EndMarks AND TermId=@TermId
end
--Insert into Term_Wise_Course_Result
---TermType added 22-11-2011
if(@TargetTerm=1)
begin
UPDATE T_Term_Std_ThesisProject_Result_Details
SET LetterGrade='X', GradePoint=0
WHERE StudentId=@StudentId AND TermId=@TermId AND CourseId=@CourseId
end
else if(@TargetTerm=2)
begin
UPDATE T_Term_Std_ThesisProject_Result_Details
SET LetterGrade=@LetterGrade, GradePoint=@GradePoint
WHERE StudentId=@StudentId AND TermId=@TermId AND CourseId=@CourseId
end
--Insert into T_Common_Student_Earned_Credit
if(@LetterGrade<>'F' AND @TargetTerm=2)
begin
--INSERT INTO T_Common_Student_Earned_Credit(TermId, RegularTerm, CourseId, StudentId, LetterGrade, GradePoint,TermType)
--VALUES(@TermId, @RegularTerm, @CourseId, @StudentId, @LetterGrade, @GradePoint,@TermType)
DECLARE @PrevTerm varchar(50), @PrevCourse varchar(50)
SELECT DISTINCT @PrevTerm=TermId,@PrevCourse=CourseId FROM T_Term_Std_ThesisProject_Result_Details WHERE TermId<>@TermId AND StudentId=@StudentId
AND ResultPrecessingStatus=0 AND CourseContinuityStatus='X'
--INSERT INTO T_Common_Student_Earned_Credit(TermId, RegularTerm, CourseId, StudentId, LetterGrade, GradePoint,TermType)
--VALUES(@PrevTerm, @RegularTerm, @PrevCourse, @StudentId, @LetterGrade, @GradePoint,@TermType)
UPDATE T_Term_Std_ThesisProject_Result_Details
SET
ResultPrecessingStatus=1
WHERE CourseId=@PrevCourse AND TermId= @PrevTerm
UPDATE T_Term_Std_ThesisProject_Result_Details
SET CourseContinuityStatus='X',
ResultPrecessingStatus=1
WHERE CourseId=@CourseId AND TermId= @TermId
end
--If Failed insert or update Common_Backlog_Info
IF(@GradePoint=0)
begin
SELECT @Count=COUNT(*)
FROM T_Common_Backlog_Info
WHERE StudentId=@StudentId AND CourseId=@CourseId
IF(@Count=0)
begin
INSERT T_Common_Backlog_Info(StudentId,TermId, CourseId)
VALUES(@StudentId, @TermId, @CourseId)
end
ELSE
begin
UPDATE T_Common_Backlog_Info SET RegistrationStatus='B' WHERE StudentId=@StudentId AND CourseId=@CourseId
end
print @Count
print 'Separate'
end
--Delete Course From BackLog If passed.......
IF(@GradePoint>0)
begin
DELETE FROM T_Common_Backlog_Info
WHERE StudentId=@StudentId AND CourseId=@CourseId
end
-- If Any errors then go for Roll Back Transaction
SELECT @intErrorCode = @@ERROR
IF (@intErrorCode <> 0) GOTO PROBLEMERROR
fetch next from TermThesisResultCursor into
@CourseId, @StudentId, @TotalMarks
end
close TermThesisResultCursor
deallocate TermThesisResultCursor
end
-- If Any errors then go for Roll Back Transaction
SELECT @intErrorCode = @@ERROR
IF (@intErrorCode <> 0) GOTO PROBLEMERROR
---15-11-2011
---------------------------------------------------------------------------------------------------------------------
--Update Result Processing Status [Result Theory]
UPDATE T_Term_Std_Result_Theory_Details
SET ResultProcessingStatus=1
WHERE TermId=@TermId
-- If Any errors then go for Roll Back Transaction
SELECT @intErrorCode = @@ERROR
IF (@intErrorCode <> 0) GOTO PROBLEMERROR
---15-11-2011
---------------------------------------------------------------------------------------------------------------------
--Update Result Processing Status [Result Laboratory]
UPDATE T_Term_Student_Result_Lab_Details
SET ResultPrecessingStatus=1
WHERE TermId=@TermId
-- If Any errors then go for Roll Back Transaction
SELECT @intErrorCode = @@ERROR
IF (@intErrorCode <> 0) GOTO PROBLEMERROR
--- 17-11-2011
-------------------------------------------- 02-01-2012---------------------------------------------------------------
-------------------------------------- 60% Attendance rule vialation handling ----------------------------------------
--- 26/01/2012 modification
--Update term result
declare TermSixtyPercentRule cursor for
select distinct CourseId
from T_Term_Course_Offer
where TermId = @TermId
open TermSixtyPercentRule
fetch next from TermSixtyPercentRule into
@CourseId
while @@FETCH_STATUS = 0
begin
declare TermSixtyPercentRuleVialation cursor for
SELECT StudentId
FROM T_StudentListBellow60PercentAttendance
WHERE CourseId = @CourseId AND TermId = @TermId
GROUP BY StudentId
open TermSixtyPercentRuleVialation
fetch next from TermSixtyPercentRuleVialation into
@StudentId
while @@FETCH_STATUS = 0
begin
UPDATE T_Term_Std_Result_Theory_Details
SET LetterGrade = 'I',
GradePoint = null
WHERE StudentId=@StudentId AND CourseId=@CourseId AND TermId = @TermId
UPDATE T_Term_Student_Result_Lab_Details
SET LetterGrade = 'I',
GradePoint = null
WHERE StudentId=@StudentId AND CourseId=@CourseId AND TermId = @TermId
fetch next from TermSixtyPercentRuleVialation into
@StudentId
end
close TermSixtyPercentRuleVialation
deallocate TermSixtyPercentRuleVialation
fetch next from TermSixtyPercentRule into
@CourseId
end
close TermSixtyPercentRule
deallocate TermSixtyPercentRule
-- If Any errors then go for Roll Back Transaction
SELECT @intErrorCode = @@ERROR
IF (@intErrorCode <> 0) GOTO PROBLEMERROR
------------------------------------------------------------------------------------------------------------------------
-------------------------------------------- 02-07-2012---------------------------------------------------------------
-------------------------------------- Exam Absent Student handling ----------------------------------------
--Update term result
declare TermExamAbsentStudent cursor for
select distinct CourseId
from T_Term_Course_Offer
where TermId = @TermId AND CourseType='Theory'
open TermExamAbsentStudent
fetch next from TermExamAbsentStudent into
@CourseId
while @@FETCH_STATUS = 0
begin
declare ExamAbsent cursor for
select data as StudentId from dbo.fn_Exam_Absent_Student(@TermId,@CourseId,',')
GROUP BY data
open ExamAbsent
fetch next from ExamAbsent into
@StudentId
while @@FETCH_STATUS = 0
begin
UPDATE T_Term_Std_Result_Theory_Details
SET LetterGrade = '-',
GradePoint = null,
Remarks='Abs'
WHERE StudentId=@StudentId AND CourseId=@CourseId AND TermId = @TermId
fetch next from ExamAbsent into
@StudentId
end
close ExamAbsent
deallocate ExamAbsent
fetch next from TermExamAbsentStudent into
@CourseId
end
close TermExamAbsentStudent
deallocate TermExamAbsentStudent
-- If Any errors then go for Roll Back Transaction
SELECT @intErrorCode = @@ERROR
IF (@intErrorCode <> 0) GOTO PROBLEMERROR
------------------------------------------------------------------------------------------------------------------------


-- 26/01/2012 modified
--------------------------- Calculation of T_Student_Credit_Status TotalEarnedCredit value ----------------------------
DECLARE
@TotalEarnedCredit decimal(18,2),
@TotalEarnedPoint decimal(18,2),
@TotalEarnedCreditTheory decimal(18,2),
@TotalEarnedPointTheory decimal(18,2),
@TotalEarnedCreditSessional decimal(18,2),
@TotalEarnedPointSessional decimal(18,2),
@TestRecord int,
@StudentCategory int
declare StudentCreditStatus cursor for
select isnull(StudentId,-1)
from T_Term_Std_Course_Reg
where TermId = @TermId
open StudentCreditStatus
fetch next from StudentCreditStatus into
@StudentId
while @@FETCH_STATUS = 0
begin
SELECT @StudentCategory=COUNT(*)from T_Term_Std_Result_Theory_Details WHERE T_Term_Std_Result_Theory_Details.LetterGrade ='F' AND T_Term_Std_Result_Theory_Details.StudentId=@StudentId
if(@StudentCategory>0)
begin
UPDATE T_Student_Credit_Status
SET StudentCategory=2
WHERE StudentId=@StudentId
end
SELECT @StudentCategory=COUNT(*)from T_Term_Student_Result_Lab_Details WHERE T_Term_Student_Result_Lab_Details.LetterGrade ='F' AND T_Term_Student_Result_Lab_Details.StudentId=@StudentId
if(@StudentCategory>0)
begin
UPDATE T_Student_Credit_Status
SET StudentCategory=2
WHERE StudentId=@StudentId
end
---- Replace T_Common_Course_Information by T_Term_Course_Offer 11-12-2011 by N@z
SELECT @TotalEarnedCreditTheory = SUM(T_Term_Course_Offer.CourseCredit)
FROM T_Term_Course_Offer INNER JOIN
T_Term_Std_Result_Theory_Details ON T_Term_Course_Offer.CourseId = T_Term_Std_Result_Theory_Details.CourseId
WHERE T_Term_Std_Result_Theory_Details.StudentId=@StudentId AND T_Term_Std_Result_Theory_Details.LetterGrade!='F'
SELECT @TotalEarnedPointTheory = SUM(T_Term_Std_Result_Theory_Details.GradePoint * T_Term_Course_Offer.CourseCredit)
FROM T_Term_Course_Offer INNER JOIN
T_Term_Std_Result_Theory_Details ON T_Term_Course_Offer.CourseId=T_Term_Std_Result_Theory_Details.CourseId
WHERE T_Term_Std_Result_Theory_Details.StudentId=@StudentId AND T_Term_Std_Result_Theory_Details.LetterGrade!='F'
SELECT @TotalEarnedCreditSessional = SUM(T_Term_Course_Offer.CourseCredit)
FROM T_Term_Course_Offer INNER JOIN
T_Term_Student_Result_Lab_Details ON T_Term_Course_Offer.CourseId = T_Term_Student_Result_Lab_Details.CourseId
WHERE T_Term_Student_Result_Lab_Details.StudentId=@StudentId AND T_Term_Student_Result_Lab_Details.LetterGrade!='F'
SELECT @TotalEarnedPointSessional = SUM(T_Term_Student_Result_Lab_Details.GradePoint * T_Term_Course_Offer.CourseCredit)
FROM T_Term_Course_Offer INNER JOIN
T_Term_Student_Result_Lab_Details ON T_Term_Course_Offer.CourseId=T_Term_Student_Result_Lab_Details.CourseId
WHERE T_Term_Student_Result_Lab_Details.StudentId=@StudentId AND T_Term_Student_Result_Lab_Details.LetterGrade!='F'
SET @TotalEarnedCredit = @TotalEarnedCreditTheory + @TotalEarnedCreditSessional
SET @TotalEarnedPoint = @TotalEarnedPointTheory + @TotalEarnedPointSessional
select @TestRecord = COUNT(*) from T_Student_Credit_Status WHERE StudentId=@StudentId
if(@TestRecord>0)
begin
UPDATE T_Student_Credit_Status
SET TotalEarnedCredit=@TotalEarnedCredit,
TotalEarnedPoint=@TotalEarnedPoint
WHERE StudentId=@StudentId
end
else if(@TestRecord=0)
begin
insert into T_Student_Credit_Status(StudentId,TotalEarnedCredit,TotalEarnedPoint)
values(@StudentId,@TotalEarnedCredit,@TotalEarnedPoint)
end
fetch next from StudentCreditStatus into
@StudentId
end
close StudentCreditStatus
deallocate StudentCreditStatus
-- If Any errors then go for Roll Back Transaction
SELECT @intErrorCode = @@ERROR
IF (@intErrorCode <> 0) GOTO PROBLEMERROR
----------------------------------------------------------------------------------------------------------------------------
--Commit Transaction if no error
commit transaction
-------------User defined label for exeption handling---------------
PROBLEMERROR:
IF (@intErrorCode <> 0)
BEGIN
--PRINT 'Unexpected error occurred!'
ROLLBACK TRAN
END
--------------------------------------------------------------------------------------------------------------------
END
---------------------------------------------------------------------------------------------------------------------
END

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s