This is the definition of a PL/SQL basic block provided by ORACLE documentation.
A basic block refers to a single entry single exit block of PL/SQL code
This is the definition of the basic block from the internet
Basic block is a set of statements that always executes in a sequence one after the other. The characteristics of basic blocks are- They do not contain any kind of jump statements in them. There is no possibility of branching or getting halted in the middle. All the statements execute in the same order they appear.
I am trying to find the code coverage of PL/SQL code using the DBMS_PLSQL_CODE_COVERAGE package and this package allows to find the PL/SQL block-level coverage. Here I have some doubts about IF-ELSIF-ELSE code coverage. The main thing is ELSE block of IF-ELSIF-ELSE is not considered as a basic block. Please refer to the following codes.
This is my first example. In the second column, all the values (0s and 1s) represent a basic block. Here you can clearly see both IF and ELSE conditions are counted as basic blocks which are pretty fair to me.
Now, this is what bothers me. Please refer to the following code.
Here you can see all IF and ELSIF blocks are counted as basic blocks, which is okay. But the ELSE block is not considered a basic block, which means, according to the definition of basic block if execution comes to the last ELSIF block, no matter what ELSE part is also get executed. This affects the code coverage percentage.
But in actual execution, this does not happen. But DBMS_PLSQL_CODE_COVERAGE package gives me this output. Could someone explain why this happens? I have no idea of the internal implementation of this package. All I know is it is using DBMS_PROFILER to get code coverage.
If you are curious that, which query provided me with the above tables here is the query.
SELECT LISTAGG(ccb.col, ',') WITHIN GROUP (ORDER BY ccb.col) AS col,
LISTAGG(ccb.covered, ',') WITHIN GROUP (ORDER BY ccb.col) AS covered,
s.line,
LISTAGG(ccb.not_feasible, ',') WITHIN GROUP (ORDER BY ccb.col) AS not_feasible,
s.text
FROM user_source s
JOIN dbmspcc_units ccu ON s.name = ccu.name AND s.type = ccu.type
LEFT OUTER JOIN dbmspcc_blocks ccb ON ccu.run_id = ccb.run_id AND ccu.object_id = ccb.object_id AND s.line = ccb.line
WHERE s.name = 'DEMO_UTILITY_TST'
AND s.type = 'PACKAGE BODY'
AND ccu.run_id = 248
GROUP BY s.line, s.text
ORDER BY 3;

