SQL Queries - CAST Knowledge Base - Queries on objects - How to get Lines of Code by object type
Purpose of Query
This page gives you the SQL queries to perform to get LoC by object type in the knowledge base
PLEASE NOTE: THE QUERIES BELOW ARE ONLY VALID IN CAST AIP 8.3.36 AND BELOW. FOR CAST AIP 8.3.37 AND ABOVE YOU MUST MODIFY THE QUERIES AS FOLLOWS:
- change references:
- properties = 0
- to
- properties & 255 = 0
Applicable CAST Version
| Release | Yes/No |
|---|---|
| 8.3.x | ✅ |
Applicable RDBMS
| RDBMS | Yes/No |
|---|---|
| Oracle Server | ✅ |
| Microsoft SQL Server | ✅ |
| CSS | ✅ |
Query for CSS
SELECT idtyp ,
typdsc ,
COUNT(object_id) ,
SUM(oi.infval)
FROM objinf oi
JOIN
(SELECT DISTINCT object_id,
object_type
FROM ctt_object_applications
WHERE properties = 0
)
coa
ON coa.object_id = oi.idobj
JOIN typ t
ON t.idtyp = coa.object_type
WHERE oi.inftyp = 1
AND oi.infsubtyp = 0
GROUP BY idtyp,
typdsc
ORDER BY idtyp,
typdsc
Query result example
137066;“C# Delegate”;4;4
137067;“C# Class”;74;12302
137068;“C# Property”;150;581
137069;“C# Property Set”;41;65
137070;“C# Property Get”;90;290
137071;“C# Constructor”;52;282
137115;“C# Interface”;2;31
137116;“C# Structure”;2;20
137117;“C# Enumeration”;14;142
137241;“C# Enumeration Item”;102;101
Query result interpretation
This query will give the LOC by objects type.
Suppose the object type is C# Class we have 74 classes and corresponding LOC is 12302.
Query for Oracle
SELECT idtyp ,
typdsc ,
COUNT(object_id) ,
SUM(oi.infval)
FROM objinf oi
JOIN
(SELECT DISTINCT object_id,
object_type
FROM ctt_object_applications
WHERE properties = 0
)
coa
ON coa.object_id = oi.idobj
JOIN typ t
ON t.idtyp = coa.object_type
WHERE oi.inftyp = 1
AND oi.infsubtyp = 0
GROUP BY idtyp,
typdsc
ORDER BY idtyp,
typdsc
Query result example
137066;“C# Delegate”;4;4
137067;“C# Class”;74;12302
137068;“C# Property”;150;581
137069;“C# Property Set”;41;65
137070;“C# Property Get”;90;290
137071;“C# Constructor”;52;282
137115;“C# Interface”;2;31
137116;“C# Structure”;2;20
137117;“C# Enumeration”;14;142
137241;“C# Enumeration Item”;102;101
Query result interpretation
This query will give the LOC by objects type.
Suppose the object type is C# Class we have 74 classes and corresponding LOC is 12302.
Query for SQL server
SELECT idtyp ,
typdsc ,
COUNT(object_id) ,
SUM(oi.infval)
FROM objinf oi
JOIN
(SELECT DISTINCT object_id,
object_type
FROM ctt_object_applications
WHERE properties = 0
)
coa
ON coa.object_id = oi.idobj
JOIN typ t
ON t.idtyp = coa.object_type
WHERE oi.inftyp = 1
AND oi.infsubtyp = 0
GROUP BY idtyp,
typdsc
ORDER BY idtyp,
typdsc
Query result example
137066;“C# Delegate”;4;4
137067;“C# Class”;74;12302
137068;“C# Property”;150;581
137069;“C# Property Set”;41;65
137070;“C# Property Get”;90;290
137071;“C# Constructor”;52;282
137115;“C# Interface”;2;31
137116;“C# Structure”;2;20
137117;“C# Enumeration”;14;142
137241;“C# Enumeration Item”;102;101
Query result interpretation
This query will give the LOC by objects type.
Suppose the object type is C# Class we have 74 classes and corresponding LOC is 12302.
Notes/comments
Related Pages