USP_ADHOCQUERYREPORT_DELETE

Executes the "Ad-hoc Query Report: 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_ADHOCQUERYREPORT_DELETE
                    (
                        @ID uniqueidentifier,
                        @CHANGEAGENTID uniqueidentifier
                    )
                    as
                        set nocount on;

                        begin try
                        declare @REPORTEXISTS bit;
                        declare @ISADHOCQUERYREPORT bit;

                        select 
                            @REPORTEXISTS = 1
                        from 
                            dbo.REPORTCATALOG
                        where
                            ID = @ID

                        if @REPORTEXISTS = 1
                        begin
                            with xmlnamespaces('bb_appfx_report' as ns, 'bb_appfx_commontypes' as c)
                            select
                                @ISADHOCQUERYREPORT = 1
                            from 
                                dbo.REPORTCATALOG
                            where
                                ID = @ID and 
                                 REPORTCATALOG.REPORTSPECXML.value('ns:ReportSpec[1]/c:MetaTags[1]/AdHocQuerySaveReportRequest[1]', 'nvarchar(max)') is not null;

                                if @ISADHOCQUERYREPORT = 1
                                    exec dbo.USP_REPORTCATALOG_DELETEBYID_WITHCHANGEAGENTID @ID, @CHANGEAGENTID;
                                else
                                    raiserror ('ERR_NON_ADHOCQUERY_REPORT',13,1);
                                return 0;
                        end

                        end try
                        begin catch
                            exec dbo.USP_RAISE_ERROR
                            return 1
                        end catch