DatabaseProcApplicationCreatedLinks
sybsystemprocssp_jdbc_getcatalogs_cts  31 Aug 14Defects Dependencies

1     /** SECTION END: CLEANUP **/
2     
3     
4     CREATE PROCEDURE sp_jdbc_getcatalogs_cts
5     as
6         declare @dbname varchar(32)
7         declare @startedInTransaction bit
8     
9         if @@trancount = 0
10        begin
11            set chained off
12        end
13    
14        /* check if we're in a transaction, before we try any select statements */
15        if (@@trancount > 0)
16            select @startedInTransaction = 1
17        else
18            select @startedInTransaction = 0
19    
20        set transaction isolation level 1
21    
22        if (@startedInTransaction = 1)
23            save transaction jdbc_keep_temptables_from_tx
24    
25        /* this will make sure that all rows are sent even if
26        ** the client "set rowcount" is differect
27        */
28    
29        set rowcount 0
30    
31        create table #tmpcatalog
32        (TABLE_CAT varchar(32) null)
33    
34        DECLARE jcurs_getcatalog CURSOR
35        FOR select name from master..sysdatabases FOR READ ONLY
36        OPEN jcurs_getcatalog
37        FETCH jcurs_getcatalog INTO @dbname
38    
39        while (@@sqlstatus = 0)
40        begin
41            insert into #tmpcatalog values (@dbname)
42            FETCH jcurs_getcatalog INTO @dbname
43        end
44        close jcurs_getcatalog
45        deallocate cursor jcurs_getcatalog
46        select TABLE_CAT from #tmpcatalog order by TABLE_CAT
47        drop table #tmpcatalog
48    
49        if (@startedInTransaction = 1)
50            rollback transaction jdbc_keep_temptables_from_tx
51    


exec sp_procxmode 'sp_jdbc_getcatalogs_cts', 'AnyMode'
go

Grant Execute on sp_jdbc_getcatalogs_cts to public
go
RESULT SETS
sp_jdbc_getcatalogs_cts_rset_001

DEFECTS
 MGTP 3 Grant to public master..sysdatabases  
 MGTP 3 Grant to public sybsystemprocs..sp_jdbc_getcatalogs_cts  
 MNER 3 No Error Check should check @@error after insert 41
 MUCO 3 Useless Code Useless Brackets 15
 MUCO 3 Useless Code Useless Brackets 22
 MUCO 3 Useless Code Useless Brackets 39
 MUCO 3 Useless Code Useless Brackets 49
 QISO 3 Set isolation level 20
 CRDO 2 Read Only Cursor Marker (has for read only clause) 35
 MRST 2 Result Set Marker 46
 MTR1 2 Metrics: Comments Ratio Comments: 13% 4
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 6 = 5dec - 1exi + 2 4
 MTR3 2 Metrics: Query Complexity Complexity: 34 4

DEPENDENCIES
PROCS AND TABLES USED
read_writes table tempdb..#tmpcatalog (1) 
reads table master..sysdatabases (1)