SQL Queries - CAST Central Base - Queries on Objects - How to get the LoC by object type

Purpose of Query

This page provide LoC by object type in the central base

Applicable CAST Version

ReleaseYes/No
8.3.x
8.2.x
8.1.x
8.0.x
7.3.x

Applicable RDBMS

RDBMSYes/No
Oracle Server
Microsoft SQL Server
CSS3
CSS2

Query for CSS and Oracle

In the below query, the results are for a particular <snapshot_id>. Provide the specific snapshot_id when running the query below.

The following TKB page can assist you in obtaining the snapshot_id: SQL Queries - CAST Central Base - Queries on snapshots - How to get the ID and name of a snapshot for a given application.

Also the metric_id used below (10151) is the metric id for the quality rule here and should be put in as the constant value 10151:

SELECT idtyp, 
       typdsc                AS Type, 
       Count(dmr.object_id)  AS NumberOfObject, 
       Sum(metric_num_value) TotalLoC 
FROM   dss_metric_results dmr 
       JOIN dss_object_info dos 
         ON dos.object_id = dmr.object_id 
       JOIN typ 
         ON idtyp = dos.object_type_id 
WHERE  dmr.metric_id = 10151 
       AND dmr.snapshot_id = <snapshot_id> 
       AND dos.snapshot_id = dmr.snapshot_id 
       AND dmr.metric_value_index = 1 
GROUP  BY idtyp, 
          typdsc 
ORDER  BY idtyp, 
          typdsc

Query result example

-102;“Application”;1;88289
512;“C/C++ File”;85;88289
20000;“Module”;1;88289
107502;“C++ Subset”;1;88289

Query result interpretation

For each object type, we get the id, the number of object per object type and the total loc per object type.

Query for SQL server

Enter the SQL query

Query result example

Query result interpretation

Notes/comments

Related Pages