PTF Tracing Part 2

Polymorphic Table Functions (PTF’s) tracing can be added to the DESCRIBE, OPEN, FETCH_ROWS and CLOSE portions of the package.

FUNCTION describe (p_tbl IN OUT DBMS_TF.TABLE_T)
  RETURN DBMS_TF.DESCRIBE_T IS
BEGIN
  DBMS_TF.TRACE( msg       => 'Hello From Describe',
                 separator => 'DESC',
                 prefix    => 'DPREFIX');
  RETURN NULL;
END;

PROCEDURE open IS
BEGIN
  DBMS_TF.TRACE( msg       => 'Hello From Open',
                 with_id   => TRUE,
                 separator => 'OPEN ',
                 prefix    => 'OPPREFIX' );
END;

PROCEDURE fetch_rows IS
BEGIN
  DBMS_TF.TRACE( msg       => 'Hello From Fetch',
                 with_id   => TRUE,
                 separator => 'FETCH ',
                 prefix    => 'FPREFIX' );
END;

PROCEDURE close IS
BEGIN
  DBMS_TF.TRACE( msg       => 'Hello From Close',
                 with_id   => TRUE,
                 separator => 'CLOSE ',
                 prefix    => 'CPREFIX' );
END;

And here is the output from a run.

DPREFIXHello From Describe
DESCDESCDESCDESCDESCDESCDESCDESCDESCDESCDESCDESCDESC
OPPREFIXHello From Open <id=0500000000000000>
OPEN OPEN OPEN OPEN OPEN OPEN OPEN OPEN OPEN OPEN OP
FPREFIXHello From Fetch <id=0500000000000000>
FETCH FETCH FETCH FETCH FETCH FETCH FETCH FETCH FETC
CPREFIXHello From Close <id=0500000000000000>
CLOSE CLOSE CLOSE CLOSE CLOSE CLOSE CLOSE CLOSE CLOS

The trace function is acutely aware of the object types PTF’s use. For example the argument (table, view or query) can be interrogated with a singe call to the trace function as shown here:

FUNCTION describe (p_tbl IN OUT DBMS_TF.TABLE_T)
  RETURN DBMS_TF.DESCRIBE_T IS
BEGIN
  DBMS_TF.TRACE( msg       => 'Hello From Describe',
                 separator => 'DESC',
                 prefix    => 'DPREFIX');
  DBMS_TF.TRACE ( tab => p_tbl );
  RETURN NULL;
END;

And here are the results.

DPREFIXHello From Describe
DESCDESCDESCDESCDESCDESCDESCDESCDESCDESCDESCDESCDESC
Schema Name:........."D"
Package Name:........."POLY_PKG"
PTF Name:........."POLY_FUNC"
........tab.column[1] =
pass through column
NOT a for read column
__________Type:...............NUMBER
__________Max Length:.........22
__________Name:..............."COL1"
__________Name Length:........6
__________Precision:..........0
__________Scale:..............-127
........tab.column[2] =
pass through column
NOT a for read column
__________Type:...............NUMBER
__________Max Length:.........22
__________Name:..............."COL2"
__________Name Length:........6
__________Precision:..........0
__________Scale:..............-127

OPPREFIXHello From Open <id=0600000000000000>
OPEN OPEN OPEN OPEN OPEN OPEN OPEN OPEN OPEN OPEN OP
FPREFIXHello From Fetch <id=0600000000000000>
FETCH FETCH FETCH FETCH FETCH FETCH FETCH FETCH FETC
CPREFIXHello From Close <id=0600000000000000>
CLOSE CLOSE CLOSE CLOSE CLOSE CLOSE CLOSE CLOSE CLOS

Thanks for reading!