USP_STUDENTENROLLMENT_DELETE

Executes the "Student Enrollment Delete" record operation.

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN Input parameter indicating the ID of the record being deleted.
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the delete.

Definition

Copy


                CREATE procedure dbo.USP_STUDENTENROLLMENT_DELETE
                (
                    @ID uniqueidentifier,
                    @CHANGEAGENTID uniqueidentifier
                )
                as begin

                    --check deletion rules, if any

                    declare @STUDENTID as uniqueidentifier
                    declare @ENTRYCOUNT as int
                    SELECT @STUDENTID = dbo.EDUCATIONALHISTORY.[CONSTITUENTID] FROM dbo.EDUCATIONALHISTORY WHERE dbo.EDUCATIONALHISTORY.[ID] = @ID
                    set @ENTRYCOUNT = (SELECT COUNT(dbo.EDUCATIONALHISTORY.[ID]) FROM dbo.EDUCATIONALHISTORY INNER JOIN dbo.SCHOOL on dbo.EDUCATIONALHISTORY.[EDUCATIONALINSTITUTIONID] = dbo.SCHOOL.[ID] WHERE dbo.EDUCATIONALHISTORY.[CONSTITUENTID] = @STUDENTID

                    if @ENTRYCOUNT <= 1 begin
                        raiserror('BBERR_STUDENTENROLLMENT_ATLEASTONE', 13, 1)
                    end

                    if dbo.UFN_STUDENTENROLLMENT_INUSE(@ID) = 1
                            raiserror('BBERR_STUDENTENROLLMENT_INUSE', 13, 1)

                    -- use the system generated delete routine to allow proper recording of the deleting agent

                    exec USP_EDUCATIONALHISTORY_DELETEBYID_WITHCHANGEAGENTID @ID, @CHANGEAGENTID
                    return 0;

                end