DatabaseProcApplicationCreatedLinks
sybsystemprocssp_ddlgen_db_print_with_clause  31 Aug 14Defects Dependencies

1     
2     /*
3     ** sp_ddlgen_db_print_with_clause
4     **
5     **	Print the WITH clauses as required, depending on whether override
6     **	has been specified, and if the other options like durability or
7     **	dml_logging need to be printed.
8     **
9     ** Parameters:
10    **	@with_override	- Boolean; whether WITH OVERRIDE should be generated.
11    **	@with_dur_and_dmllog
12    **			- Boolean; whether WITH DURABILITY AND DML_LOGGING
13    **			  should be generated.
14    **	@durability	- DURABILITY setting of db
15    **	@dmllogging	- DML_LOGGING setting of db
16    **	@archivedb	- Boolean; whether it's an archive db.
17    **	@with_dcomp_and_IRL
18    **			- Boolean; whether WITH COMPRESSION, LOB_COMPRESSION and 
19    **			  INROW_LOB_LENGTH should be generated.
20    **	@data_compression	- data compression setting of db
21    **	@lob_compression	- lob compression setting of db
22    **	@inrow_lob_length	- inrow lob length of db
23    **
24    ** Returns:	0 always.
25    {
26    */
27    create procedure sp_ddlgen_db_print_with_clause(
28        @with_override tinyint output
29        , @with_dur_and_dmllog tinyint output
30        , @with_dcomp_and_IRL tinyint output
31        , @durability varchar(13) = NULL
32        , @dmllogging varchar(9) = NULL
33        , @data_compression varchar(4) = NULL
34        , @lob_compression int
35        , @inrow_lob_length int
36        , @archivedb tinyint
37    ) as
38        begin
39            declare @newline char(1)
40                , @tabchar char(1)
41                , @override_sql varchar(13)
42                , @printfmt varchar(10) -- Check its length before use.
43                , @withopt_sep varchar(10) -- indentation for starting
44                -- new clause on a new line.
45                , @nextopt_sep varchar(10) -- indentation for the next 
46                -- WITH option.
47                , @dmllogging_full_sql varchar(4)
48                , @data_compression_none_sql varchar(4)
49    
50            select @newline = char(10)
51                , @tabchar = char(9)
52                , @override_sql = "WITH OVERRIDE"
53                , @withopt_sep = "WITH "
54                , @nextopt_sep = "   , "
55                , @dmllogging_full_sql = "FULL"
56                , @data_compression_none_sql = "NONE"
57    
58            -- If any disk piece in the current block of rows
59            -- had a WITH OVERRIDE setting, then generate that
60            -- clause here.
61            --
62            if (@with_override = 1)
63            begin
64                select @printfmt = case @archivedb
65                        when 1 then "-- %1!"
66                        else "%1!"
67                    end
68                print @printfmt, @override_sql
69    
70                -- Now that WITH OVERRIDE has been printed, re-set the
71                -- indentation string for the remaining WITH options on the
72                -- next line.
73                --
74                select @withopt_sep = @nextopt_sep
75                    , @with_override = 0
76            end
77    
78            -- Print remaining WITH options, using the appropriate indentation
79            -- separator.
80            --
81            if (@with_dur_and_dmllog = 1)
82            begin
83                if (@durability IS NOT NULL)
84                begin
85                    print "%1!DURABILITY = %2!"
86                        , @withopt_sep, @durability
87                    select @withopt_sep = @nextopt_sep
88                end
89    
90                if (@dmllogging != @dmllogging_full_sql)
91                begin
92                    print "%1!DML_LOGGING = %2!"
93                        , @withopt_sep, @dmllogging
94                    select @withopt_sep = @nextopt_sep
95                end
96    
97                select @with_dur_and_dmllog = 0
98            end
99    
100           -- Print remaining WITH options, using the appropriate indentation
101           -- separator.
102           --
103           if (@with_dcomp_and_IRL = 1)
104           begin
105               if ((@data_compression IS NOT NULL) and (@data_compression != @data_compression_none_sql))
106               begin
107                   print "%1!COMPRESSION = %2!"
108                       , @withopt_sep, @data_compression
109                   select @withopt_sep = @nextopt_sep
110               end
111   
112               if (@lob_compression != 0)
113               begin
114                   print "%1!LOB_COMPRESSION = %2!"
115                       , @withopt_sep, @lob_compression
116                   select @withopt_sep = @nextopt_sep
117               end
118   
119   
120               if ((@inrow_lob_length IS NOT NULL) and (@inrow_lob_length != 0))
121               begin
122                   print "%1!INROW_LOB_LENGTH = %2!"
123                       , @withopt_sep, @inrow_lob_length
124                   select @withopt_sep = @nextopt_sep
125               end
126   
127               select @with_dcomp_and_IRL = 0
128           end
129   
130           print "go%1!%2!", @newline, @newline
131   
132           return 0
133   
134       end
135   

DEFECTS
 MUCO 3 Useless Code Useless Brackets in create proc 27
 MUCO 3 Useless Code Useless Begin-End Pair 38
 MUCO 3 Useless Code Useless Brackets 62
 MUCO 3 Useless Code Useless Brackets 81
 MUCO 3 Useless Code Useless Brackets 83
 MUCO 3 Useless Code Useless Brackets 90
 MUCO 3 Useless Code Useless Brackets 103
 MUCO 3 Useless Code Useless Brackets 105
 MUCO 3 Useless Code Useless Brackets 112
 MUCO 3 Useless Code Useless Brackets 120
 VNRD 3 Variable is not read @tabchar 51
 VNRD 3 Variable is not read @withopt_sep 124
 MTR1 2 Metrics: Comments Ratio Comments: 36% 27
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 11 = 10dec - 1exi + 2 27
 MTR3 2 Metrics: Query Complexity Complexity: 38 27

DEPENDENCIES
CALLERS
called by proc sybsystemprocs..sp_ddlgen_db_print_alterdb  
   called by proc sybsystemprocs..sp_ddlgen_database  
called by proc sybsystemprocs..sp_ddlgen_database