DatabaseProcApplicationCreatedLinks
sybsystemprocssp_get_bigtimediff  14 déc. 14Defects Propagation Dependencies

1     
2     
3     /*
4     ** sp_get_bigtimediff
5     **
6     **	Get the difference in two BIGTIME input values (start/end) and break
7     ** 	the elapsed time into individual time component fields, upto the
8     **	microsecond granularity.
9     **
10    ** Parameters:
11    **	@start	- Start of time interval (expected to be < @end)
12    **	@end	- End of time interval
13    **
14    ** Returns:
15    **	@time_hr	- # of hours elapsed
16    **	@time_min	- # of mins elapsed
17    **	@time_s		- # of seconds elapsed
18    **	@time_ms	- # of millisecs elapsed
19    **	@time_ucs	- # of microsecs elapsed
20    **	@time_total_ucs	- # Total # of microsecs elapsed
21    {
22    */
23    create or replace procedure sp_get_bigtimediff(
24        @start bigtime
25        , @end bigtime
26        , @time_hr unsigned bigint = 0 output
27        , @time_min unsigned bigint = 0 output
28        , @time_s unsigned bigint = 0 output
29        , @time_ms unsigned bigint = 0 output
30        , @time_ucs unsigned bigint = 0 output
31        , @time_total_ucs
32        unsigned bigint = 0 output
33    ) as
34        begin
35            declare @tmptime bigtime
36    
37            if (@start > @end)
38            begin
39                set @tmptime = @start
40                set @start = @end
41                set @end = @tmptime
42            end
43    
44            set @time_total_ucs = datediff(us, @start, @end)
45    
46            set @time_ucs = @time_total_ucs
47            set @time_ms = (@time_ucs / 1000)
48            set @time_ucs = (@time_ucs % 1000)
49    
50            set @time_s = (@time_ms / 1000)
51            set @time_ms = (@time_ms % 1000)
52    
53            set @time_min = (@time_s / 60)
54            set @time_s = (@time_s % 60)
55    
56            set @time_hr = (@time_min / 60)
57            set @time_min = (@time_min % 60)
58        end -- }
59    


exec sp_procxmode 'sp_get_bigtimediff', 'AnyMode'
go

Grant Execute on sp_get_bigtimediff to public
go
DEFECTS
 MGTP 3 Grant to public sybsystemprocs..sp_get_bigtimediff  
 MUCO 3 Useless Code Useless Brackets in create proc 23
 MUCO 3 Useless Code Useless Begin-End Pair 34
 MUCO 3 Useless Code Useless Brackets 37
 MUCO 3 Useless Code Useless Brackets 47
 MUCO 3 Useless Code Useless Brackets 48
 MUCO 3 Useless Code Useless Brackets 50
 MUCO 3 Useless Code Useless Brackets 51
 MUCO 3 Useless Code Useless Brackets 53
 MUCO 3 Useless Code Useless Brackets 54
 MUCO 3 Useless Code Useless Brackets 56
 MUCO 3 Useless Code Useless Brackets 57
 MTR1 2 Metrics: Comments Ratio Comments: 36% 23
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 3 = 2dec - 1exi + 2 23
 MTR3 2 Metrics: Query Complexity Complexity: 17 23

DEPENDENCIES
CALLERS
called by proc sybsystemprocs..sp_prt_bigtimediff  
   called by proc sybsystemprocs..sp_spaceused