DatabaseProcApplicationCreatedLinks
sybsystemprocssp_versioncrack  31 Aug 14Defects Dependencies

1     
2     /*
3     **	SP_VERSIONCRACK
4     **
5     **	A utility procedure to parse a version string and extract desired
6     **	information from it and return it to the caller.
7     **
8     **	Parameter
9     **		@str 	    - the version string to be parsed.
10    **		@keywordstr - the keyword defining what information is to be
11    **			      extracted.
12    **
13    **	Returns
14    **		- the desired value/information string.
15    **		- the desired value int.
16    **
17    **		0 - if all goes well.
18    **		1 - if any error while parsing. 
19    **
20    {
21    */
22    create procedure sp_versioncrack
23    (
24        @str varchar(255)
25        , @keywordstr varchar(30)
26        , @outstr varchar(30) OUT
27        , @outint int OUT
28    )
29    as
30        begin -- {
31    
32            declare @esdpattern varchar(10)
33                , @ebfpattern varchar(10)
34                , @pattern varchar(30)
35                , @esdkeyword varchar(4)
36                , @ebfkeyword varchar(4)
37                , @leftstr varchar(255)
38                , @rightstr varchar(255)
39                , @spaceindex int
40                , @slashindex int
41                , @stopatindex int
42                , @retval int
43    
44            select @outstr = NULL
45                , @outint = - 1
46                , @esdpattern = "ESD#"
47                , @ebfpattern = "EBF "
48                , @esdkeyword = "ESD"
49                , @ebfkeyword = "EBF"
50                , @keywordstr = upper(ltrim(rtrim(@keywordstr)))
51                , @spaceindex = 0
52                , @slashindex = 0
53    
54            /*
55            ** If @str is NULL or @keywordstr is NULL, sp_split_string will return
56            ** NULL. So, need not handle that case.
57            */
58    
59            select @pattern = case @keywordstr
60                    when @ebfkeyword then @ebfpattern
61                    when @esdkeyword then @esdpattern
62                    else NULL
63                end
64    
65            if @pattern = NULL -- Invalid keyword string.	
66                return 1
67    
68            -- Extract the requested value form @str.
69            exec @retval = sp_split_string @str, @pattern, 0, @leftstr out
70                , @rightstr out
71    
72            if @retval = 1
73            begin
74                -- The keyword pattern not found in @str. Or @str is NULL.
75                return 1
76            end
77    
78            select @spaceindex = charindex(' ', @rightstr)
79            select @slashindex = charindex('/', @rightstr)
80    
81            select @stopatindex = case
82                    when @spaceindex = 0 then @slashindex - 1
83                    when @slashindex = 0 then @spaceindex - 1
84                    when @spaceindex < @slashindex
85                    then @spaceindex - 1
86                    else @slashindex - 1
87                end
88    
89            if @stopatindex <= 0
90            begin
91                -- No space, nor slash, found in @rightstr.
92                -- At this moment, for ESD or EBF, this can not be so, so return
93                -- with error.
94                --
95                return 1
96            end
97    
98            select @outstr = substring(@rightstr, 1, @stopatindex)
99    
100           if @outstr is not NULL
101           begin
102   
103               -- Check if it is an integer value, if so, get the value. The
104               -- check for '$' is added because isnumeric will return 1 for
105               -- money data type also. 
106               --
107               if ((isnumeric(@outstr) = 1) and (charindex('$', @outstr) = 0))
108               begin
109                   select @outint = convert(int, @outstr)
110               end
111           end
112   
113           return 0
114   
115       end -- }	-- }
116   


exec sp_procxmode 'sp_versioncrack', 'AnyMode'
go

Grant Execute on sp_versioncrack to public
go
DEFECTS
 MGTP 3 Grant to public sybsystemprocs..sp_versioncrack  
 MNAC 3 Not using ANSI 'is null' 65
 MUCO 3 Useless Code Useless Brackets in create proc 23
 MUCO 3 Useless Code Useless Begin-End Pair 30
 MUCO 3 Useless Code Useless Brackets 107
 VNRD 3 Variable is not read @leftstr 69
 MTR1 2 Metrics: Comments Ratio Comments: 35% 22
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 5 = 6dec - 3exi + 2 22
 MTR3 2 Metrics: Query Complexity Complexity: 28 22

DEPENDENCIES
PROCS AND TABLES USED
calls proc sybsystemprocs..sp_split_string  

CALLERS
called by proc sybsystemprocs..sp_mon_archive_genSQL  
   called by proc sybsystemprocs..sp_mon_archive_monTable  
      called by proc sybsystemprocs..sp_mon_archive_deadlock  
   called by proc sybsystemprocs..sp_monitor_deadlock  
      called by proc sybsystemprocs..sp_monitor  
called by proc sybsystemprocs..sp_spaceusage_object_init  
   called by proc sybsystemprocs..sp_spaceusage_object  
      called by proc sybsystemprocs..sp_spaceusage  
called by proc sybsystemprocs..sp_spaceusage_tranlog_init  
   called by proc sybsystemprocs..sp_spaceusage_tranlog  
      called by proc sybsystemprocs..sp_spaceusage