config.usp_init_parameter - P

type: P ( stored procedure ), modify_date: 2021-10-02 13:23:34

RepoObject_guid: 8D90291C-9D61-EB11-84DC-A81E8446D5B0

Description

Examples

Entity Diagram

entity-config.usp_init_parameter

References

Object Reference Diagram - 1 1

entity_1_1_objectref-config.usp_init_parameter

Object Reference Diagram - Referenced - 30 0

entity_30_0_objectref-config.usp_init_parameter

Object Reference Diagram - Referencing - 0 30

entity_0_30_objectref-config.usp_init_parameter

sql_modules_definition

config.usp_init_parameter - P script
/*
<<property_start>>Description
* merges default values for parameters from xref:sqldb:configt.parameter_default.adoc[] into xref:sqldb:config.parameter.adoc[]
<<property_end>>
*/
CREATE Procedure config.usp_init_parameter
As
--
Insert Into config.Parameter
(
    Parameter_name
  , sub_Parameter
  , Parameter_desciption
  , Parameter_default_value
)
Select
    T1.Parameter_name
  , T1.sub_Parameter
  , T1.Parameter_desciption
  , T1.Parameter_default_value
From
    configT.Parameter_default As T1
Where
    Not Exists
(
    Select
        1
    From
        config.Parameter As target
    Where
        target.Parameter_name    = T1.Parameter_name
        And target.sub_Parameter = T1.sub_Parameter
);

Update
    T2
Set
    T2.Parameter_desciption = source.Parameter_desciption
  , T2.Parameter_default_value = source.Parameter_default_value
From
    config.Parameter              As T2
    Inner Join
        configT.Parameter_default As source
            On
            source.Parameter_name    = T2.Parameter_name
            And source.sub_Parameter = T2.sub_Parameter
Where
    --we need case sensitive compairison
    T2.Parameter_desciption Collate Latin1_General_100_CS_AS       <> source.Parameter_desciption Collate Latin1_General_100_CS_AS
    Or
    (
        T2.Parameter_desciption Is Null
        And Not source.Parameter_desciption Is Null
    )
    Or
    (
        Not T2.Parameter_desciption Is Null
        And source.Parameter_desciption Is Null
    )
    Or T2.Parameter_default_value Collate Latin1_General_100_CS_AS <> source.Parameter_default_value Collate Latin1_General_100_CS_AS
    Or
    (
        T2.Parameter_default_value Is Null
        And Not source.Parameter_default_value Is Null
    )
    Or
    (
        Not T2.Parameter_default_value Is Null
        And source.Parameter_default_value Is Null
    );