USP_WEBDASHBOARDFOLDER_DELETE

Deletes a web dashboard folder and all its contents.

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN
@CHANGEAGENTID uniqueidentifier IN

Definition

Copy


create procedure dbo.USP_WEBDASHBOARDFOLDER_DELETE(@ID uniqueidentifier, @CHANGEAGENTID uniqueidentifier)
as
    set nocount on;

    declare @contextCache varbinary(128);

    /* cache current context information */
    set @contextCache = CONTEXT_INFO();

    /* set CONTEXT_INFO to @CHANGEAGENTID */
    if not @CHANGEAGENTID is null
        set CONTEXT_INFO @CHANGEAGENTID;

    -- Delete any existing pages belonging to the folder.

    delete from dbo.WEBDASHBOARDPAGECATALOG where WEBDASHBOARDFOLDERID = @ID;

    /* reset CONTEXT_INFO to previous value */
    if not @contextCache is null
        set CONTEXT_INFO @contextCache;

    declare @CHILDID uniqueidentifier;

    -- Recursively delete any child folders belonging to this folder.

    declare c cursor local for select ID from dbo.WEBDASHBOARDFOLDER where PARENTID = @ID;
    open c;

    fetch next from c into @CHILDID;

    if @CHILDID is not null
        exec dbo.USP_WEBDASHBOARDFOLDER_DELETE @CHILDID, @CHANGEAGENTID;

    while @@fetch_status = 0
    begin
        fetch next from c into @CHILDID;
        if @CHILDID is not null
            exec dbo.USP_WEBDASHBOARDFOLDER_DELETE @CHILDID, @CHANGEAGENTID;
    end;

    close c;
    deallocate c;

    exec dbo.USP_WEBDASHBOARDFOLDER_DELETEBYID_WITHCHANGEAGENTID @ID, @CHANGEAGENTID;