USP_CONDITIONSETTING_DELETEBYNAME_WITHCHANGEAGENTID

Removes a condition setting for the given key.

Parameters

Parameter Parameter Type Mode Description
@NAME nvarchar(100) IN
@CHANGEAGENTID uniqueidentifier IN

Definition

Copy


create procedure dbo.USP_CONDITIONSETTING_DELETEBYNAME_WITHCHANGEAGENTID
(
    @NAME nvarchar(100),
    @CHANGEAGENTID uniqueidentifier = null
)
as 
    /*    
    Sets Context Info to the CHANGEAGENTID
    Deletes a row in the CONDITIONSETTING table with the given NAME
    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);

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

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

    delete from dbo.CONDITIONSETTING where CONDITIONSETTING.NAME = @NAME;

    /* 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;