USP_DATAFORMTEMPLATE_ADD_REPORTSNAPSHOT

The save procedure used by the add dataform template "Report Snapshot Add Form".

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier INOUT The output parameter indicating the ID of the record added.
@REPORTCATALOGID uniqueidentifier IN Input parameter indicating the context ID for the record being added.
@HISTORYID nvarchar(20) IN Report history ID
@NAME nvarchar(50) IN Name
@DESCRIPTION nvarchar(300) IN Description
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the procedure.

Definition

Copy

                    CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_REPORTSNAPSHOT
                    (
                        @ID uniqueidentifier = null output,
                        @REPORTCATALOGID uniqueidentifier,
                        @HISTORYID nvarchar(20),
                        @NAME nvarchar(50),
                        @DESCRIPTION nvarchar(300) = '',
                        @CHANGEAGENTID uniqueidentifier
                    )
                    as
                        set nocount on

                        if @CHANGEAGENTID is null
                            exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output

                        declare @CURRENTDATE datetime
                        set @CURRENTDATE = getdate()

                        if @ID is null
                            set @ID = newid()

                        begin try
                            -- Pull parameters from the linked report
                            declare @PARAMETERS xml
                            select @PARAMETERS = PARAMETERS
                            from dbo.REPORTPARAMETERS
                            where ID = @REPORTCATALOGID

                            insert into dbo.REPORTSNAPSHOT
                            (
                                ID,
                                REPORTCATALOGID,
                                HISTORYID,
                                NAME,
                                DESCRIPTION,
                                PARAMETERS,
                                ADDEDBYID, CHANGEDBYID, DATEADDED, DATECHANGED
                            )
                            values
                            (
                                @ID,
                                @REPORTCATALOGID,
                                @HISTORYID,
                                @NAME,
                                coalesce(@DESCRIPTION, ''),
                                @PARAMETERS,
                                @CHANGEAGENTID, @CHANGEAGENTID, @CURRENTDATE, @CURRENTDATE
                            )
                        end try
                        begin catch
                            exec dbo.USP_RAISE_ERROR
                            return 1
                        end catch

                        return 0