SQL Queries - CAST Knowledge Base - Queries on metrics and diagnostics - How to get the Number of code lines at application or system level in the Knowledge Base
Purpose
This page explains how to get the number of code lines at application/system level in the knowledge Base. The page is relevant for the following cases:
- One application with more than one module.
- One system with more than one application.
- One system with one application containing more than one module.
Applicable in CAST Version
| Release | Yes/No |
|---|---|
| 8.3.x | ✅ |
Applicable RDBMS
| RDBMS | Yes/No |
|---|---|
| Oracle Server | ✅ |
| Microsoft SQL Server | ✅ |
| CSS | ✅ |
Details
If the Number of code line is calculated at the System level
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
Get the list of APPLICATION_ID(s) belonging to the identified system:on Central base
SELECT site_object_id FROM dss_translation_table WHERE object_id IN (SELECT module_id FROM dss_central_selection where application_id IN (SELECT next_object_id FROM dss_links WHERE previous_object_id IN (SELECT object_id FROM dss_objects WHERE object_name LIKE ‘<system_name>’ ) ) )
For example:
```java
SELECT site_object_id
FROM dss_translation_table
WHERE object_id IN (SELECT module_id
FROM dss_central_selection where application_id
IN (SELECT next_object_id
FROM dss_links
WHERE
previous_object_id IN (SELECT
object_id
FROM
dss_objects
WHERE
object_name LIKE '%My System%' )
)
)
-- 95510
--174003
Query for Number Of Code Lines on Knowledge base:
SELECT SUM(infval) FROM objinf WHERE idobj IN (SELECT DISTINCT ( object_id ) FROM ctt_object_applications WHERE application_id IN (list of APPLICATION_ID) AND properties = 0) AND inftyp = 1 AND infsubtyp = 0
For example:
```java
SELECT SUM(infval)
FROM objinf
WHERE idobj IN (SELECT DISTINCT ( object_id )
FROM ctt_object_applications
WHERE application_id IN (95510, 174003)
AND properties = 0)
AND inftyp = 1
AND infsubtyp = 0
If the Number of code lines is calculated at Application level
Get list of APPLICATION_ID(s) belonging to the identified Application on Central base:
SELECT object_id FROM dss_objects WHERE object_id IN (SELECT module_id FROM dss_central_selection WHERE application_id IN (SELECT object_id FROM dss_objects where OBJECT_NAME like’<application_name>’))
For example:
```sql
SELECT object_id
FROM dss_objects
WHERE object_id IN (SELECT module_id
FROM dss_central_selection
WHERE application_id IN (SELECT object_id
FROM dss_objects where OBJECT_NAME like'%cpp%'))
--5652
--5702
Query for Number of code Lines on Knowledge base:
SELECT SUM(infval) FROM objinf WHERE idobj IN (SELECT DISTINCT ( object_id ) FROM ctt_object_applications WHERE application_id IN (list of APPLICATION_ID) AND properties = 0) AND inftyp = 1 AND infsubtyp = 0
For example:
```sql
SELECT SUM(infval)
FROM objinf
WHERE idobj IN (SELECT DISTINCT ( object_id )
FROM ctt_object_applications
WHERE application_id IN (5652,5702)
AND properties = 0)
AND inftyp = 1
AND infsubtyp = 0
Notes/comments
Related Pages
CAST Engineering Dashboard - Metrics - Lines of code - Unexpected increase or decrease