spDelete_ClientRoles

Parameters

Parameter Parameter Type Mode Description
@PKID int IN
@CurrentUsersID int IN

Definition

Copy

                CREATE   PROCEDURE [dbo].[spDelete_ClientRoles]
                (
                    @PKID        int,
                    @CurrentUsersID    int
                )
                AS

                DECLARE @Guid uniqueidentifier
                DECLARE @ChapterRoleMessage nvarchar(256)
                DECLARE @ChapterFound bit

                exec [dbo].spRoleInUseByChapter @ChapterFound OUTPUT, @ChapterRoleMessage OUTPUT, @PKID

                if @ChapterFound = 1
                    BEGIN
                        RAISERROR(@ChapterRoleMessage,16,1)
                    END
                ELSE    
                    BEGIN
                        begin transaction
                        declare @roleguid uniqueidentifier
                        select @roleguid = [guid] from ClientRoles where ID=@PKID 
                        delete from CLIENTROLECHILD where (PARENTCLIENTROLEID = @PKID or CHILDCLIENTROLEID = @PKID)
                        delete from clientroles where id=@PKID
                        delete from RoleObjectPrivs where ClientRolesID=@PKID
                        delete from CMSOBJETSECURITYEXCEPTION where EXCEPTIONOBJECTGUID = @roleguid
                    /*
                        Update ClientRoles set Deleted = 1 where ID = @PKID
                        select @Guid = Guid from ClientRoles where ID = @PKID
                        exec spAuditThis @CurrentUsersID, 3, @Guid, 7
                    */
                        commit
                    END