The activation of the feature in the APEX very specific access control

Hello

does anyone know how to do?


Reading around it seems that this characteristic to be able to provide online access control is only a part of the Enterprise edition. However, it certainly is not because there is a tutorial on how to implement that in the APEX. However, when I write that it comes up with the error above, however characteristic is not activate. It comes to mount the virtual private database that allows you to access control of line.
I guess that the line of code that would mean ' private access is one that says: policy_function = > "user only.


BEGIN
DBMS_RLS.add_policy
(object_schema = > 'data_schema',)
object_name = > 'EMPLOYEES. "
POLICY_NAME = > "EMP_SEL_POL"
function_schema = > 'HR ',.
policy_function = > 'USER_ONLY ',.
statement_types = > 'SELECT');
END;
/




Thank you very much

Published by: Alvaroe on February 3, 2010 10:37

Fine-grain Access Control (MEV) is a feature available only in the as detailed here http://www.oracle.com/database/product_editions.html Oracle database Enterprise edition
If you have a license for the EA, then you can exercise the hooks which provides the APEX in interface with the VPD policies defined in the database.

CITY

Tags: Database

Similar Questions

  • APEX calendar 5.0 - edit privilege access control

    Hello experts,

    Is it possible to access to the APEX 5.0 calendar control - privilege to change so the user cannot click in the calendar to add/edit events? I have disabled all these sites, it looks like this, where the user wishes to add/edit events:

    But I want to do, so that the user cannot click in calendar thanks to the privilege of change. Is this possible?

    Thank you.

    Zajcev

    Zajcev wrote:

    Is it possible to access to the APEX 5.0 calendar control - privilege to change so the user cannot click in the calendar to add/edit events? I have disabled all these sites, it looks like this, where the user wishes to add/edit events:

    But I want to do, so that the user cannot click in calendar thanks to the privilege of change. Is this possible?

    I see no easy way and sure to implement this exact requirement, A read only attribute exists in the region of calendar, but as several other properties properties it it has no effect on the civilian component made.

    What I would say is rather to make the details read-only pages when users have no permissions to change rather than block access entirely. You can do so with a type of PL/SQL Expression condition in the reading of the section only, page level using the apex_authorization.is_authorized method to assess the approval scheme:

    not apex_authorization.is_authorized('EDIT_EVENT')

    If the detail pages contains data that users are not allowed to access, use the authorisation schemes as usual to avoid areas or elements of rendering.

  • No idea how to configure the e-mail feature in oracle apex

    Hi guys please could someone help me understand how the E-mail present works in the apex I know it works at the level of page processing, but it could also work to the level of the table

    For example

    : When a user connects to a survey application, and they are supposed to do four quotas and they do only two how would I created the e-mail feature to remind them to complete the other two remaining assessments

    Send email to a trigger from the table. The trigger could count the number of assessments and if the 2 have been completed, an e-mail can be sent.

    If you don't want to use a trigger just use dbms_scheduler to run a task once a day, week, etc., to find people who have completed only 2 ratings and send them an email.

  • Active Directory can authenticate to the APEX development environment

    Greetings,

    Environment:
    Apex Version 4.0.2
    Database version: 11.2.0.1
    WebLogic 10.3.3
    Listener of the apex

    Is it possible to use Active Directory to authenticate access to the APEX development environment? I have all the individual applications using Active Directory authentication, but I can't find a way to integrate Active Directory to access the development environment.

    Thank you
    Larry

    Larry,

    No, you cannot change the way in which the APEX Application Builder authenticates users.

    brgds,
    Peter

    -----
    Blog: http://www.oracle-and-apex.com
    ApexLib: http://apexlib.oracleapex.info
    BuilderPlugin: http://builderplugin.oracleapex.info
    Work: http://www.click-click.at

  • Activation of the APEX on new installation 11.2 (Windows)

    Can someone point me to the documentation on how to enable the APEX? I just finished the Setup and connection of an Oracle 11 g R2 database on Windows 2008R2 Standard. I can see APEX related patterns for 3.2, but I can't find anything in the documentation that tells me how to activate it. I installed APEX starting with 1.0 on 10g - just do not know where to go from here. I'd appreciate any help.

    Hello

    http://docs.Oracle.com/CD/E14373_01/install.32/e13366/db_install.htm#CIHGAGGB

    Kind regards
    Jari

    http://dbswh.webhop.NET/dbswh/f?p=blog:Home:0

  • Conversion of HTML to the APEX form

    I use 5 APEX and need to replicate some features on an existing HTML (see below) form. I need to have a button on my page that will send (redirect URL with action) and pass these 3 hidden items. The item values for 'ac', and 'table' will be static, but the value 'list' should be dynamic and together (PLSQL) process. Can someone give me the best way to achieve this on the APEX page.

    "< are method ="POST"action="/admin/home.html ">

    < input type = "hidden" name = "ac" value = "buildsel" >

    < input type = "hidden" name = "table" value = "Students" >

    < input type = "hidden" name = "list" value = "1,2,3" >

    < / make >

    So, your problem is not passing the values to the homepage, but get values in the order of the day?

    There are several options, depending on your Apex page needs. For example, your article 'list' can have a "PL/SQL function body ': source

    declare

    v_return varchar2 (100);

    Start

    because loop me in 1.3

    v_return: = v_return | ',' || TO_CHAR (i);

    end loop;

    Ltrim (v_return, ',') return;

    end;

  • CSS box does not not at the APEX 5

    I have a 25 request theme in a 5 APEX environment that renders a checkbox as described here

    http://cssdeck.com/Labs/iPhone-style-checkbox

    The problem is the check box is not activating / disabling click after upgrade to the APEX 5 or the #P1_AVAILABLE click event handler in the case below

    My final output is as follows

    <label id="slider_P1_AVAILABLE" class="sliderLabel">
      <input type="checkbox" name="p_t13" id="P1_AVAILABLE" checked="" value="A">
      <span id="slider">
        <span id="sliderOn"></span>
        <span id="sliderOff"></span>
        <span id="sliderBlock"></span>
      </span>
    </label>
    

    In previous environments by adding this

    $('#P1_AVAILABLE_CONTAINER').on('click', function(e) {console.log(e.target)});
    


    returns responses for the scope and the entrance.

    <span id="sliderOn"></span>
    <input type="checkbox" name="p_t13" id="P1_AVAILABLE" checked="" value="A">
    


    In my APEX 5 app it returns only

    <span id="sliderOn"></span>

    as if the click event is not reproducing all the possibilities in the tag, or something like that.


    Unfortunately not replicable so far

    https://Apex.Oracle.com/pls/Apex/f?p=73000:38:

    But I thought someone might suggest something to look out, or if it is a diversion to another question.

    See you soon

    It seems that this problem has been fixed in 5.0.1, but I have a similar problem with radio groups

    Group of radio buttons do not change after upgrade to apex 5

  • can anyone provide a link to insert the image with the text on the button in the apex 4.2.6

    can anyone provide a link to insert the image with the text on the button in the apex 4.2.6

    ReemaPuri wrote:

    in the workspace image:-resign.jpeg

    As a button? Seriously?

    Ok. First of all, because the image already contains text, there no point in including the same wording in the form of text on the button. Accessibility requirements can be met using re-sign as alternative text. 4.2, create an image button:

    Tag/Alt text: Re-sign

    Static ID: re - sign

    Style button: Image

    Button Image: & WORKSPACE_IMAGES.resign.jpeg

    To make the image looks more like a button, add the following CSS to Inline CSS property page:

    #re-sign img {
      margin: 0 2px 2px 0;
      border: 2px outset;
      border-radius: 4px;
    }
    #re-sign img:active {
      margin: 2px 0 0 2px;
      border: 2px inset;
      border-radius: 4px;
    }
    

    Finally, there is a bug in 4.2 that generates the incorrect URL for the button images, which requires dynamic action of Page Load to fix.

    Event: Loading the page

    Action: Run the JavaScript Code

    Code

    var resignImg = $("#re-sign img");
    resignImg.attr("src", resignImg.attr("src").replace("/i/", ""));
    
  • Error ora-02019 in PL/SQL call in the apex, but not in a SQL Client

    Hello

    I encountered a strange problem. I have a process page type PL/SQL that runs on submit a form.

    This process calls a PL/SQL package function.

    When I run the PL/SQL Code from a SQL, for example SQL Navigator Client it works without problems.

    When trying to run from the APEX, it is always fails with the error:

    ORA-02019: description of the connection to the remote database not found

    It's the SAME code in both situations.

    It's the process code:

    DECLARE

    v_result INTEGER. v_result_msg VARCHAR2 (4000);

    v_ref_date DATE; v_reset INTEGER.

    BEGIN

    -Prepare the arguments

    v_ref_date: = TO_DATE (: P73_REFERENCE_DATE, ' DD/MM/YYYY');

    v_reset: =: P73_RESET;

    -Use the feature

    TRC.trc_jobs.xade_daily_job (v_ref_date, v_reset, v_result, v_result_msg);

    END;

    When I debug Apex I trace to the bottom of the error, in a job that makes a join with a table in a database link.

    It is the offending function:

    FUNCTION (p_series_name IN VARCHAR2, p_date AS get_series_cfi_code,

    p_date_active_flag in FULL)

    RETURN VARCHAR2

    IS

    v_cfi_code instrument_type.full_cfi_code@dl_herds%TYPE;

    CURSOR c_get_series_cfi_code IS

    SELECT it.full_cfi_code

    I, instrument_type@dl_herds INSTRUMENTS it

    WHERE i.series_name = p_series_name

    AND ((i.expiration_date = p_date AND p_date_active_flag = 0) OR)

    (i.expiration_date > = p_date AND p_date_active_flag = 1))

    AND i.product_id2 = it.id

    ORDER BY i.expiration_date;

    BEGIN

    OPEN c_get_series_cfi_code.

    SEEK c_get_series_cfi_code INTO v_cfi_code;

    CLOSE C_get_series_cfi_code;

    RETURN v_cfi_code;

    END get_series_cfi_code;

    No idea why this is happening?

    I think to reproduce the table locally to eliminate the use of dblink as a last resort.

    APEX Version: 4.2.4.00.08

    Database version: 12.1.0.1.0

    NLS: UTF - 8

    TIA,

    Dionisis

    Are you sure that the dblink is accessible from the scheme of the analysis of the application? Run the code in your sql client in the same pattern?

  • Tips and advice from Expert in the APEX

    Hello Expert,

    I have a question, I was asked to look at a few applications that were built with Oracle Portal, lots of procedures for Oracle that will generate the html. Oracle does not support Oracle Portal and my organization is trying to use the following procedures to create the same type of Application Oracle apex. I have no idea on the Oracle Portal but, I can understand the instructions of orders which will result in the p/sql in HTML a bit.

    My question for those who have already worked on Oracle Portal, is adviceble to reuse these procedure and generate forms and html in APEX as Oracle APEX generate heaps of HTML as well.

    Someone at - it had the same problem when they did move to Oracle Portal, Oracle apex? How do they proceed? What was the results? Anyone can lead me to a site or a blog for more information on how to treat and to conduct this type of conversion?

    feel free to send me an e-mail to [email protected]

    Hello

    Years ago, I worked with Oracle Portal for a client who wanted a number of paper translated forms online forms. We did it creating PL/SQL procedures that generated HTML forms (and with javascript) - and the link to launch the PL/SQL procedure was published on the portal page.

    To develop these forms and manage transactions in the database has been VERY heavy.

    APEX is a great framework that allows you to declaratively set all parts of the form. There is also much more features and capabilities of formatting, validations, etc. session state.

    I think you will find that the effort required to create a PL/SQL procedure that generates an HTML form can quickly and easily be created in a few minutes in the wizards of the APEX.

    I'd say it's best to re-create each of your forms using the framework of APEX, you will find many more features. This should be pretty easy to do a proof of Concept, if you already have your database of the portal database table definitions.

    Have you had a glance at some of the samples form on apex.oracle.com?

    Amanda.

  • PL/SQL, used in application of the APEX of unit tests

    question by my client:

    I develop an Oracle Application Express application and work on unit tests for stored procedures in PL/SQL and the packages that are stored in the underlying database and used by the application of the APEX. These unit tests must run in the context of SQL Developer Unit Test.
    The problem is that the PL/SQL code stored in the database using functions such as NV('APPLICATION_ITEM') to access items in the application of the apex. They do return all values when I try to execute the PL/SQL within the unit test framework, that is to say in the backend. While it is good that the NV is not error, NULL haven't really work well in my scenario either (for example when the result of this function is inserted into a column NOT NULL in a table). I can think of a few workarounds, such as the creation of my own function NV within the schema to test return values desirable, but nothing seems a really satisfactory solution. I wonder if there is no recommendation to Oracle for this scenario - how can I run code that uses the APEX via backend-specific features. I found nothing in the documentation of the APEX for this but I would like to know if there is a recommendation how to better deal with this case.

    I use SQL Developer version 4.0.0.13.80

    Hello

    Indeed, you must set your PL/SQL function calls. This would be the cleanest solution.

    There is an alternative. Please see the following article on the creation of an APEX in PL/SQL session: Martin Giffy D'Souza on Oracle APEX: how to create a Session of the APEX in PL/SQL

    This approach allows to set the values of APEX application item before you run your unit tests. I don't know if it's possible in SQL Developer Unit Test, but it might get you further down the road.

    Good luck

    Nick

  • Pass variable header OAM at the Apex and read it in application of the Apex

    We have integrated access Manager Oracle 11 GR 1 material with Oracle Apex 4.1. OAM-Apex integration works very well. Now we want a variable header additional to pass to the application of the Apex of the OAM. This new header variable will be the user's sAMAccountName in Active Directory. OAM is integrated with AD and AD successfully users access the applications of the Apex.

    The header three variables that are set up in OAM right now are:
    Name of the variable header value
    1 OAM_REMOTE_USER $user.userid
    2 OAM_REMOTE_USER_EMAIL $user.attr.mail
    3 OAM_REMOTE_USER_GROUPS $user.groups

    We need a variable to page header as mentioned below:
    The header variable name: OAM_SAMACCOUNTNAME
    Value: $user.attr.samaccountname

    The new header variable has been added in the file dads.conf of the OHS server as shown below:
    = dads.conf =.
    ...
    PlsqlCGIEnvironmentList HTTP_OAM_REMOTE_USER
    PlsqlCGIEnvironmentList HTTP_OAM_REMOTE_USER_GROUPS
    PlsqlCGIEnvironmentList HTTP_OAM_REMOTE_USER_EMAIL
    PlsqlCGIEnvironmentList HTTP_OAM_SAMACCOUNTNAME
    ...
    ===============================

    But we are not able to read the value of this attribute in the application of the Apex.

    The application of the Apex, there is a text box that displays the value of this header variable. This text box is attached to the following stored procedure call to retrieve the header variable:
    ===================
    Start
    : P1_HEADER_VALUE: = owa_util.get_cgi_env ("HTTP_OAM_SAMACCOUNTNAME");
    end;
    ===================

    The text box displays the correct value only if HTTP_OAM_REMOTE_USER is passed to the get_cgi_env method, but shows nothing when HTTP_OAM_SAMACCOUNTNAME is passed to the same method.

    Please let me know if Miss me some configurations to pass the variable to anna64 HTTP_OAM_SAMACCOUNTNAME OAM to the Summit.

    Thanks for your help.

    Hi 900202,

    You can run

    begin
        sys.owa_util.print_cgi_env;
    end;
    

    in the SQL commands to see all headers. Maybe OAM_SAMACCOUNTNAME went without an HTTP_ prefix or its value is null, because there is a configuration problem in OAM.

    Kind regards
    Christian

  • Oracle form functions and procedures in the APEX, how?

    I'm working to recreate in the APEX, already existing read only forms in Oracle Forms. Report features interactive APEX among other things, in fact worth as well as to target a different audience than utilizies versions of Oracle Form. Versions of Oracle Forms use a lot of pre and post query triggers, PLSQL functions.

    In Oracle Forms that places, these functions can be found in the "Units of program" section of the form. A feature typical of this kind, based on a particular Mission ID route, collecting names of regular passengers, is shaped with a comma and a space after each of them, in a single string that is returned and displayed the list of passengers of a line.

    I have all of this written code so I can move most of the main request of the Oracle form in an interactive report. These functions and triggers called in the form of the "Units of program" section of the Oracle form rather than stored in the database schema in a package, where they would go inside the APEX? Can I create a 'shortcut' in the APEX and call it from the interactive report "Source Région"? I can create the PLSQL function at the level of the region of the interactive report or page level? Or, my best bet creates a package that is stored in the database, all these functions and/or proecedures I might need the original form of Oracle?

    Some advice would be greatly appreciated.

    RLBickham wrote:
    I don't think I've been pretty clear in the description of the specific thing I want to do, simply, it does not reach the level of forms of conversion of the APEX. It is basically a problem of PLSQL function.

    I have an interactive report which is currently 90 percent of what I want however, each line, which represents a Mission may have several feet. Each arm has two places or ICAO codes attached to it. Based on the number of Mission, I want to loop through the array of leg, collect all the codes of ICAO for this Mission, put them together in 1 variable separated by a coma and add this variable to display the columns in this interactive report as the last column.

    In Oracle Forms, I have a function registered in the database, which is called in the main query. Maybe I ask a question that does not need to be asked, but anyway my question is can I put this function currently in the database somewhere within the interactive report and somehow reference it via Http, or should I just stick with set of functions and procedures in the packages stored in the database and called the conventional way?

    You could switch the function to the database and call it from the report query, but it sounds as if it were superfluous. In the report query using any form of Re: 4. How can I convert rows to columns? is appropriate for your version of the (unspecified) database.

    -----

    When you have a problem, you will get an answer faster, more efficient including information as much information as possible from the outset. This should include:

  • Full version of APEX
  • Complete operating system DB, version, edition, host
  • Architecture of Web server (EPG, SST or APEX listener/host operating system)
  • Browser (s) and version (s) used
  • Theme
  • Model (s)

  • Region/section type (s) (particularly as to distinguish if a 'report' is a standard report, an interactive report, or indeed a 'update report' (i.e. a tabular presentation))

    With APEX, we also had the chance to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproduce things is the best way to solve most of the questions, particularly those relating to the layout and Visual formatting. If you expect a detailed response it is appropriate that you take on an important part of the effort by getting as much as possible with an example of the problem on apex.oracle.com before asking for help on specific issues, then we can see firsthand.

  • How to run queries of BSE within the APEX

    Hi gurus

    I want to run inside the APEX of a complex query extracted a simultaneous R11 EBS, but this application has many features such as USERENV('LANG') and USERENV('CLIENT_INFO').
    How can I set this info in order to run this application?
    I know that the values of these parameters, but my problem is to put

    Any help will be rewarded
    Oscar

    You must initialize a context apps before do anything associated EBS. The most common place for it is in the section of DTV application (renamed the PLSQL pre-rendered or something like that since 4 APEX).
    Use a call to fnd_global.apps_initialize. You must pass the appropriate values for the user, the responsibility, application etc.

  • How do the query select outer join to a report of the APEX

    Hi all

    I'm Ann.

    I have a select statement that is used to calculate statistics for a month (October 2012 in this example)
    Select ph.phase_number
    sum ((case
    WHEN ph.date_finished IS NULL or ph.date_finished > last_day (TO_DATE (' ' Oct 2012 ', ' MY YYYY' "))
    THEN last_day (TO_DATE (' ' Oct 2012 ', ' MY YYYY' "))
    Of OTHER ph.date_finished
    END)
    (-ph.date_started + 1) / count (def.def_id) as avg_days
    Ph phase_membership
    inner join court_engagement this on ph.mpm_eng_id = ce.engagement_id
    join in-house defendant def on ce.defendant_id = def.def_id
    where def.active = 1
    and ph.date_started < = last_day (TO_DATE (' ' Oct 2012 ', ' MY YYYY' "))
    and ph.active = 1
    and UPPER (ce.court_name) LIKE '% '.
    Rollup Group (phase_number)
    ;

    The result is as below
    Phase_Number AVG_DAYS
    Phase One 8.6666666666666667
    Phase two 14.6
    Phase three 12
    11.4615365

    I have another list of selection mainly the list of months between two date value.
    Select to_char (which_month, 'LUN YYYY') as display_month
    de)
    Select add_months (to_date (' ' August 2012 ', ' MY YYYY' "), rownum-1) which_month
    of object
    where
    rownum < = months_between (to_date (' ' Oct 2012 ', ' MY YYYY' "), add_months (to_date (' ' August 2012", "MY YYYY"), - 1))
    order of which_month)

    The query result is as below

    DISPLAY_MONTH

    AUGUST 2012
    SEP 2012
    OCT 2012

    Is it possible I can join these two select statement above to generate a comparable result:

    Days of month Phase number Avg
    August 2012 Phase One 8.666
    Sep 2012 Phase One 7.66
    Oct 2012 Phase One 5,66
    August 2012 Phase two 8.666
    Sep 2012 Phase two 7.66
    Oct 2012 Phase two 5,66
    August 2012 Phase three 8.666
    Sep 2012 Phase three 7.66
    Oct 2012 Phase three 5,66

    Or
    Days of month Phase number Avg
    August 2012 Phase One 8.666
    August 2012 Phase two 7.66
    August 2012 Phase three 5,66
    Sep 2012 Phase One 8.666
    Sep 2012 Phase two 7.66
    Sep 2012 Phase three 5,66
    Oct 2012 Phase One 8.666
    Oct 2012 Phase two 7.66
    Oct 2012 Phase three 5,66

    And it can be controlled by Phase number or month.
    My other colleague suggested I should use a left outer join, but after having tried many ways, I'm still stuck.

    I tried select is
    Select a.display_month, b.* in)
    Select to_char (which_month, 'LUN YYYY') as display_month
    de)
    Select add_months (to_date (' ' August 2012 ', ' MY YYYY' "), rownum-1) which_month
    of object
    where
    rownum < = months_between (to_date (' ' Oct 2012 ', ' MY YYYY' "), add_months (to_date (' ' August 2012", "MY YYYY"), - 1))
    order which_month)) a left outer join

    (Select to_char (ph.date_finished, 'MY YYYY') as join_month, ph.phase_number)
    sum ((case
    WHEN ph.date_finished IS NULL or ph.date_finished > last_day (TO_DATE (a.display_month, 'MY YYYY'))
    THEN last_day (TO_DATE (a.display_month, 'MY YYYY'))
    Of OTHER ph.date_finished
    END)
    (-ph.date_started + 1) / count (def.def_id) as avg_days
    Ph phase_membership
    inner join court_engagement this on ph.mpm_eng_id = ce.engagement_id
    join in-house defendant def on ce.defendant_id = def.def_id
    where def.active = 1
    and ph.date_started < = last_day (TO_DATE (a.display_month, 'MY YYYY'))
    and ph.active = 1
    and UPPER (ce.court_name) LIKE '% '.
    To_char (ph.date_finished, 'MY YYYY'), group (phase_number) rollup) b
    On a.display_month = b.join_month

    but then I get an error
    SQL error: ORA-00904: "A." "" DISPLAY_MONTH ": invalid identifier

    I need to view a report on the APEX with option for people to download at least format CSV.
    Already 1 inteactive report in the page, so I don't think adds another interactive report without using the iframe trick.

    If any of you have any ideas, please help.

    Thank you very much.

    Ann

    Hello Ann,.

    Frank has done a very good job. I am also impressed.

    Is in regard to your correction to his question, the problem is on this replacement you did

    last_day(TO_DATE(am.which_month,'MON YYYY'))
    

    AM.which_month is already a date type, and you don't need to convert it to this day.
    Here is the correct way:

    last_day(am.which_month)
    

    There are also sometimes with the data you've posted have no line for this month. So I also added a function NVL to display 0 under avg_days for these cases.

    Here is my corrected query:

    DEFINE startmonth = "Aug 2012";
    DEFINE endmonth   = "Oct 2012";
    WITH  all_months  AS
    (
       SELECT ADD_MONTHS(to_date('&startmonth','MON YYYY'), ROWNUM-1) AS which_month
       ,      ADD_MONTHS(to_date('&startmonth','MON YYYY'), ROWNUM  ) AS next_month
       from all_objects
       where
       rownum <= months_between(to_date('&endmonth','MON YYYY'), add_months(to_date('&startmonth','MON YYYY'), -1))
    )
    SELECT TO_CHAR (am.which_month, 'Mon YYYY')  AS month
         , ph.phase_number
         , NVL(sum ( (CASE
                     WHEN ph.date_finished IS NULL OR ph.date_finished > last_day(am.which_month)
                     THEN last_day(am.which_month)
                     ELSE ph.date_finished
                  END
                 ) - ph.date_started + 1
               ) / count(def.def_id), 0) as avg_days
      FROM all_months am
           LEFT OUTER JOIN  a_phase_membership  ph  PARTITION BY (ph.phase_number)
              ON  am.which_month <= ph.date_started
              AND am.next_month  >  ph.date_started
              AND ph.date_started <= last_day(am.which_month)  -- May not be needed
              AND ph.active = 1
           LEFT OUTER JOIN  a_engagement  ce
              ON  ph.mpm_eng_id = ce.engagement_id
              AND ce.court_name IS NOT NULL  -- or something involving LIKE
           LEFT OUTER join  a_defendant     def
              ON  ce.defendant_id = def.def_id
              AND def.active = 1
     GROUP BY ROLLUP(phase_number, am.which_month)
     ORDER BY  am.which_month
            ,  ph.phase_number
    ;
    
    The output is:
    MONTH    PHASE_NUMBER           AVG_DAYS
    -------- -------------------- ----------
    Aug 2012 PHASE ONE                     0
    Aug 2012 PHASE THREE                   0
    Aug 2012 PHASE TWO                     0
    Sep 2012 PHASE ONE                    12
    Sep 2012 PHASE THREE                   1
    Sep 2012 PHASE TWO                     9
    Oct 2012 PHASE ONE                     8
    Oct 2012 PHASE THREE                   0
    Oct 2012 PHASE TWO                    14
             PHASE ONE                    11
             PHASE THREE                   1
             PHASE TWO                  11.5
                                  9.71428571
    

    I don't know if that's really what you want. In the case check it and let me know.

    Kind regards.
    Al

Maybe you are looking for