DatabaseProcApplicationCreatedLinks
sybsystemprocssp_lmconfig  31 Aug 14Defects Dependencies

1     
2     /*
3     ** Messages for "sp_lmconfig"
4     **
5     ** 17260, "Can't run %1! from within a transaction."
6     */
7     create procedure sp_lmconfig
8         @configname varchar(255) = NULL, /* license config option name */
9         @configvalue varchar(255) = "1" /* license config value */
10    as
11        declare @config_id int /* config id for dbcc lmconfig */
12        declare @configvaluelen int /* length of license config value */
13    
14    
15        /*
16        ** dbcc lmconfig is not allowed in a transaction.
17        */
18        if @@trancount > 0
19        begin
20            /*
21            ** 17260, "Can't run %1! from within a transaction."
22            */
23            raiserror 17260, "sp_lmconfig"
24            return (1)
25        end
26    
27        set chained off
28    
29        set transaction isolation level 1
30    
31        /*
32        ** Check if user has SA role, proc_role will also do auditing
33        ** if required. proc_role will also print error message if required.
34        */
35    
36        if (proc_role("sa_role") = 0)
37            return (1)
38    
39        if (@configname is NULL)
40        begin
41            /* Display all license configuration and license status */
42            dbcc lmconfig
43        end
44        else
45        begin
46            /* Map config name to config id for dbcc lmconfig. */
47            select @config_id = case @configname
48                    when "edition" then 1
49                    when "license type" then 2
50                    when "smtp host" then 3
51                    when "email recipients" then 4
52                    when "email severity" then 5
53                    when "smtp port" then 6
54                    when "email sender" then 7
55                    else 0
56                end
57    
58            if (@config_id = 0)
59            begin
60                print "Error: No matching configuration options."
61                return (1)
62            end
63            else if (@configvalue = "1")
64            begin
65                /* (@config_id != 0) and (@configvalue is not specified) */
66                /* Display the license configuration */
67                dbcc lmconfig(@config_id)
68            end
69            else
70            begin
71                /* (@config_id != 0) and (@configvalue is specified) */
72                /* Set the license configuration */
73                if (@configvalue is null)
74                begin
75                    select @configvalue = "null"
76                end
77                select @configvaluelen = datalength(@configvalue)
78                dbcc lmconfig(@config_id, @configvalue, @configvaluelen)
79            end
80        end
81    
82        return (0)
83    

DEFECTS
 MUCO 3 Useless Code Useless Brackets 24
 MUCO 3 Useless Code Useless Brackets 36
 MUCO 3 Useless Code Useless Brackets 37
 MUCO 3 Useless Code Useless Brackets 39
 MUCO 3 Useless Code Useless Brackets 58
 MUCO 3 Useless Code Useless Brackets 61
 MUCO 3 Useless Code Useless Brackets 63
 MUCO 3 Useless Code Useless Brackets 73
 MUCO 3 Useless Code Useless Brackets 82
 QISO 3 Set isolation level 29
 MTR1 2 Metrics: Comments Ratio Comments: 36% 7
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 5 = 6dec - 3exi + 2 7
 MTR3 2 Metrics: Query Complexity Complexity: 29 7

DEPENDENCIES