| Database | Proc | Application | Created | Links |
| sybsystemprocs | sp_gen_timerange_id | ![]() | 31 Aug 14 | Defects Dependencies |
1 2 /* Sccsid = "%Z% generic/sproc/%M% %I% %G%" */ 3 4 create procedure sp_gen_timerange_id 5 @newmaxid int output 6 as 7 8 declare @msg varchar(250) 9 declare @curmaxid int 10 declare @curcount int 11 declare @searchcount int 12 13 /* Create a unique ID for the range */ 14 select @curcount = count(*) from master.dbo.systimeranges 15 select @curmaxid = max(id) from master.dbo.systimeranges 16 if (@curcount = 0) 17 select @newmaxid = 1 18 else if (@curcount >= 0.8 * convert(double precision, @curmaxid)) 19 /* More than 80% full */ 20 select @newmaxid = @curmaxid + 1 21 else 22 begin 23 /* Try five random numbers between 1 and @curmaxid+1 */ 24 select @newmaxid = 1 + convert(double precision, @curmaxid) * rand() 25 select @searchcount = 1 26 while (exists (select id from master.dbo.systimeranges 27 where id = @newmaxid)) 28 begin 29 if (@searchcount = 5) 30 break 31 select @newmaxid = 1 + convert(double precision, @curmaxid) * rand() 32 select @searchcount = @searchcount + 1 33 end 34 if (@searchcount = 5) 35 select @newmaxid = @curmaxid + 1 36 end 37 38 return (0) 39 40
exec sp_procxmode 'sp_gen_timerange_id', 'AnyMode' go Grant Execute on sp_gen_timerange_id to public go
| DEFECTS | |
QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int | 27 |
QTYP 4 Comparison type mismatch smallint = int | 27 |
TNOU 4 Table with no unique index master..systimeranges | master..systimeranges |
MGTP 3 Grant to public master..systimeranges | |
MGTP 3 Grant to public sybsystemprocs..sp_gen_timerange_id | |
MUCO 3 Useless Code Useless Brackets | 16 |
MUCO 3 Useless Code Useless Brackets | 18 |
MUCO 3 Useless Code Useless Brackets | 26 |
MUCO 3 Useless Code Useless Brackets | 29 |
MUCO 3 Useless Code Useless Brackets | 34 |
MUCO 3 Useless Code Useless Brackets | 38 |
VUNU 3 Variable is not used @msg | 8 |
MSUB 2 Subquery Marker | 26 |
MTR1 2 Metrics: Comments Ratio Comments: 15% | 4 |
MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 6 = 5dec - 1exi + 2 | 4 |
MTR3 2 Metrics: Query Complexity Complexity: 30 | 4 |
| DEPENDENCIES |
| PROCS AND TABLES USED reads table master..systimeranges (1) CALLERS called by proc sybsystemprocs..sp_add_time_range |