Oracle DBMS_PLSQL_CODE_COVERAGE
Version 19.3

General Information
Library Note Morgan's Library Page Header
For how many years have you been working with physical servers that are starving your database of the memory necessary to deploy important new performance features such as the Result Cache, Memoptimize Pool, In-Memory Aggregation, In-Memory Column Store, and Full Database Caching? Too long? Contact me to learn how to improve all queries ... not just some queries.
Purpose Collects code coverage data for PL/SQL applications at the basic block level. A basic block is defined as a single entry single exit block of PL/SQL code in a user's program.

The user must supply a collection of filter_list_elem which is a schema, unit name pair for the list of units that the user is interested in gathering coverage information about.
AUTHID CURRENT_USER
Data Types TYPE filter_list_elem IS RECORD(
schema VARCHAR2(ORA_MAX_NAME_LEN+2),
uname  VARCHAR2(ORA_MAX_NAME_LEN+2));

TYPE filter_list_type IS TABLE OF filter_list_elem;

SUBTYPE VARCHAR2_NOT_NULL IS VARCHAR2 NOT NULL;
Dependencies
DBMS_PLSQL_CODE_COVERAGE_LIB PLSQL_CODE_COVERAGE_RUNNUMBER USER_OBJECTS
Documented Yes
Exceptions
Error Code Reason
ORA-08402 Coverage error
First Available 12.2.0.1
Security Model Owned by SYS with EXECUTE granted to PUBLIC
Source {ORACLE_HOME}/rdbms/admin/dbmscov.sql
Subprograms
 
CREATE_COVERAGE_TABLES
This procedure creates the coverage tables dbms_plsql_code_coverage.create_coverage_tables(force_it IN BOOLEAN := FALSE);
exec dbms_plsql_code_coverage.create_coverage_tables(TRUE);

SQL> SELECT object_name, created
  2  FROM dba_objects
  3* WHERE created > sysdate-1/360;

OBJECT_NAME CREATED
------------------------------ --------------------
DBMSPCC_RUNS                   25-MAR-2019 01:19:53
DBMSPCC_RUNS_PK                25-MAR-2019 01:19:53
DBMSPCC_UNITS                  25-MAR-2019 01:19:53
DBMSPCC_UNITS_PK               25-MAR-2019 01:19:53
DBMSPCC_BLOCKS                 25-MAR-2019 01:19:53
DBMSPCC_BLOCKS_PK              25-MAR-2019 01:19:53

6 rows selected.
 
START_COVERAGE
Starts coverage data collection at the basic block level in the user's session dbms_plsql_code_coverage.start_coverage(run_comment IN VARCHAR2)
RETURN NUMBER;
SELECT dbms_plsql_code_coverage.start_coverage('Code Coverage Run 1') AS START_CVG
FROM dual;

START_CVG
---------
       16
 
STOP_COVERAGE
Stopping coverage flushes the coverage data to a file dbms_plsql_code_coverage.stop_coverage;
exec dbms_plsql_code_coverage.stop_coverage;
 
Demo
PL/SQL developers want to know how well their test infrastructure exercised their code. A typical code coverage run in a session will look like this conn sys@pdbdev as sysdba

CREATE DIRECTORY ctemp AS 'C:/TEMP';
GRANT ALL ON DIRECTORY ctemp TO uwclass;

conn uwclass/uwclass@pdbdev

-- create a proc or two here.

exec dbms_plsql_code_coverage.create_coverage_tables(

exec dbms_plsql_code_coverage.start_coverage(

-- run procs here

exec dbms_plsql_code_coverage.stop_coverage;

exec dbms_plsql_code_coverage.analyze_coverage;

- examine output here

Related Topics
Built-in Functions
Built-in Packages
Directories
What's New In 18cR3
What's New In 19cR3

Morgan's Library Page Footer
This site is maintained by Dan Morgan. Last Updated: This site is protected by copyright and trademark laws under U.S. and International law. © 1998-2019 Daniel A. Morgan All Rights Reserved
DBSecWorx