Search code examples
oracle-databaseoracle-warehouse-builder

OWB wb_rt_constants definition


I am am trying to understand a piece of SQL which I cannot execute unfortunately . I am stuck on one part of code where

     wb_rt_constants.to_string (e.audit_status) AS audit_status_symbol

I cannot seem to find what wb_rt_constants.to_string does ? is it some sort of decode ? Can some one explain what

wb_rt_constants.to_string

is trying to do , preferably definition of wb_rt_constants.to_string will be highly appreciated ?


Solution

  • Unfortunately the package body OWBSYS.wb_rt_constants is wrapped so we can't see the source code of its implementation.

    Anyway, the function to_string has the following signature:

    function to_string(p_constant in number) return varchar2;
    

    It is used in some OWBSYS views, such as ALL_RT_AUDIT_EXECUTIONS and seems to translate a numeric ID into a descriptive string, e.g.

    col execution_audit_status format a20
    
    select distinct e.audit_status,
           wb_rt_constants.to_string(e.audit_status) as execution_audit_status
      from wb_rt_audit_executions e;
    
    AUDIT_STATUS EXECUTION_AUDIT_STAT
    ------------ --------------------
           16002 BUSY
           16004 COMPLETE
    

    Those numbers seems to match the output of these functions of the same package:

    select wb_rt_constants.EXECUTION_STATUS_INACTIVE,
           wb_rt_constants.EXECUTION_STATUS_BUSY,
           wb_rt_constants.EXECUTION_STATUS_READY,
           wb_rt_constants.EXECUTION_STATUS_COMPLETE
      from dual;
    
    EXECUTION_STATUS_INACTIVE EXECUTION_STATUS_BUSY EXECUTION_STATUS_READY EXECUTION_STATUS_COMPLETE
    ------------------------- --------------------- ---------------------- -------------------------
                        16001                 16002                  16003                     16004