USP_STUDENT_CLASS_DROP
Executes the "Student Class Drop" record operation.
Parameters
| Parameter | Parameter Type | Mode | Description | 
|---|---|---|---|
| @ID | nvarchar(73) | 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_STUDENT_CLASS_DROP
(
    @ID nvarchar(73),
    @CHANGEAGENTID uniqueidentifier
)
as begin
    --check deletion rules, if any
    declare @CLASSID uniqueidentifier
    declare @STUDENTID uniqueidentifier
    select
        @CLASSID = cast(substring(@ID,1,36) as uniqueidentifier),
        @STUDENTID = cast(substring(@ID,38,36) as uniqueidentifier)
    -- use the system generated delete routine to allow proper recording of the deleting agent
    declare @contextCache varbinary(128);
    declare @e int;
    set @contextCache = CONTEXT_INFO();
    /* set CONTEXT_INFO to @CHANGEAGENTID */
    if not @CHANGEAGENTID is null
        set CONTEXT_INFO @CHANGEAGENTID;
    delete from dbo.STUDENTCLASSMEETINGGROUP
    from dbo.STUDENTCLASSMEETINGGROUP
        inner join dbo.STUDENTCOURSE on STUDENTCLASSMEETINGGROUP.STUDENTCOURSEID = STUDENTCOURSE.ID
        inner join dbo.CLASSMEETINGGROUP on STUDENTCLASSMEETINGGROUP.CLASSMEETINGGROUPID = CLASSMEETINGGROUP.ID    
    where STUDENTCOURSE.STUDENTID = @STUDENTID
        and CLASSMEETINGGROUP.CLASSID = @CLASSID
    select @e=@@error;
    -- reset CONTEXT_INFO to previous value 
    if not @contextCache is null
        set CONTEXT_INFO @contextCache;
    if @e <> 0
        return 2;
    return 0;    
end