USP_VANITYURL_DELETEBYID_WITHCHANGEAGENTID

Parameters

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

Definition

Copy

        CREATE PROCEDURE dbo.USP_VANITYURL_DELETEBYID_WITHCHANGEAGENTID(@ID INT,@CHANGEAGENTID UNIQUEIDENTIFIER=NULL)
        AS

        /*    
            Sets Context Info to the CHANGEAGENTID
            Deletes a row in the VANITYURL table with the given ID
            Resets Context info to the previous value

            The Context Info will be used by delete triggers to log the AUDITCHANGEAGENTID 
            as the supplied @CHANGEAGENTID rather than the default change agent id.
          */

         set nocount on;

         declare @e int;
         declare @contextCache varbinary(128);
       declare @SEQUENCEID int;

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

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

          select @SEQUENCEID=REALMID from dbo.VANITYURL where ID=@ID;
          delete from dbo.VANITYURL where ID=@ID;
          delete from dbo.FAFFRIENDLYURLPARAMS where SEQUENCEID=@SEQUENCEID;

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

        select @e=@@error;

        if @e<>0 return -456; --always return non-zero sp result if an error occurs

        return 0;