DatabaseProcApplicationCreatedLinks
sybsystemprocssp_odbc_databases  14 déc. 14Defects Propagation Dependencies

1     
2     
3     /* Sccsid = "%Z% generic/sproc/%M% %I% %G%" */
4     
5     CREATE OR REPLACE PROCEDURE sp_odbc_databases
6     as
7     
8         declare @startedInTransaction bit
9         if (@@trancount > 0)
10            select @startedInTransaction = 1
11        else
12            select @startedInTransaction = 0
13    
14    
15    
16        if @@trancount = 0
17        begin
18            set chained off
19        end
20    
21        set transaction isolation level 1
22    
23        if (@startedInTransaction = 1)
24            save transaction odbc_keep_temptable_tx
25    
26    
27        /* Use temporary table to sum up database size w/o using group by */
28        create table #databases(
29            database_name varchar(32),
30            size int)
31    
32        /* Insert row for each database */
33        insert into #databases
34        select
35            name,
36                (select sum(size) from master.dbo.sysusages
37                where dbid = d.dbid)
38        from master.dbo.sysdatabases d
39    
40        select
41            database_name,
42            /* Convert from number of pages to K */
43            database_size = size * (@@maxpagesize / 1024),
44            remarks = convert(varchar(254), null) /* Remarks are NULL */
45        from #databases
46    
47        drop table #databases
48        if (@startedInTransaction = 1)
49            rollback transaction odbc_keep_temptable_tx
50    
51        return (0)
52    


exec sp_procxmode 'sp_odbc_databases', 'AnyMode'
go

Grant Execute on sp_odbc_databases to public
go
RESULT SETS
sp_odbc_databases_rset_001

DEFECTS
 MGTP 3 Grant to public master..sysdatabases  
 MGTP 3 Grant to public master..sysusages  
 MGTP 3 Grant to public sybsystemprocs..sp_odbc_databases  
 MNER 3 No Error Check should check @@error after insert 33
 MUCO 3 Useless Code Useless Brackets 9
 MUCO 3 Useless Code Useless Brackets 23
 MUCO 3 Useless Code Useless Brackets 48
 MUCO 3 Useless Code Useless Brackets 51
 MUIN 3 Column created using implicit nullability 28
 QISO 3 Set isolation level 21
 MRST 2 Result Set Marker 40
 MSUC 2 Correlated Subquery Marker 36
 MTR1 2 Metrics: Comments Ratio Comments: 15% 5
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 6 = 5dec - 1exi + 2 5
 MTR3 2 Metrics: Query Complexity Complexity: 27 5
 PRED_QUERY_COLLECTION 2 {d=master..sysdatabases, u=master..sysusages} 0 36

DEPENDENCIES
PROCS AND TABLES USED
read_writes table tempdb..#databases (1) 
writes table sybsystemprocs..sp_odbc_databases_rset_001 
reads table master..sysusages (1)  
reads table master..sysdatabases (1)