Oracle DBMS_WRR_STATE
Version 18.3.0.1

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 Constants that can be used to determine whether Workload Capture and Replay are currently active
AUTHID N/A
Constants
Name Data Type Value
Capture_On BOOLEAN ( dbms_workload_capture.get_state() = 1 );
Replay_On BOOLEAN ( dbms_workload_replay.get_state() = 1 );
Dependencies
DBMS_RANDOM DBMS_WORKLOAD_CAPTURE DBMS_WORKLOAD_REPLAY
Documented No
First Available 12.2.0.1
Security Model Owned by SYS with EXECUTE granted to the DBA and EXECUTE_CATALOG_ROLE roles.
Source {ORACLE_HOME}/rdbms/admin/dbmswrr.sql

check dbmsrand.sql
 
Demo
WRR State Demo The following demo code is from $ORACLE_HOME/rdbms/admin/dbmsrand.sql and shows how these constants are used.
FUNCTION value RETURN NUMBER PARALLEL_ENABLE IS
 randval NUMBER;
BEGIN
  IF sys.dbms_wrr_state.Replay_On THEN
    randval := replay_random_number();
   IF randval IS NOT NULL THEN
      RETURN randval;
    END IF;
  END IF;

  counter := counter + 1;
  IF counter >= 55 THEN
    -- initialize if needed
    IF (need_init = TRUE) THEN
      seed(TO_CHAR(SYSDATE,'MM-DD-YYYY HH24:MI:SS') || USER || USERENV('SESSIONID'));
    ELSE
    -- need to generate 55 more results
      FOR i IN 0..30 LOOP
        randval := mem(i+24) + mem(i);
        IF (randval >= 1.0) THEN
          randval := randval - 1.0;
        END IF;
        mem(i) := randval;
      END LOOP;

      FOR i IN 31..54 LOOP
        randval := mem(i-31) + mem(i);
        IF (randval >= 1.0) THEN
          randval := randval - 1.0;
        END IF;
        mem(i) := randval;
      END LOOP;
    END IF;
    counter := 0;
  END IF;

  IF sys.dbms_wrr_state.Capture_On THEN
    record_random_number(mem(counter));
  END IF;

  RETURN mem(counter);
END value;
/

Related Topics
Built-in Functions
Built-in Packages
DBMS_WORKLOAD_CAPTURE
DBMS_WORKLOAD_REPLAY
What's New In 12cR2
What's New In 18cR3

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