Join the query in a dynamic list of values query

I have a join query in a dynamic list of values query. The value does not return a value of text, but rather the value of the ID.

Is it possible to use a join query in a dynamic list of values query?

For example... in the query below, I expect to see ename in the drop-down list, but I see class_emp_id.

Select b.ename d, a.class_emp_id r
of class_emp a, b of the emp
where a.class_cat_id =: CURR_CLASS_CAT_ID
and a.emp_id = b.emp_id
order by 1

Thank you
Reid

Hey Reid,

The structure of the pairings/value of the item is incorrect - it should be: item1, item2, etc.: value1, value2, etc, so:

' f ? p = & APP_ID.: 50: & SESSION. ": P50_LP_ID, P50_LP_NAME, CURR_CLASS_CAT_ID: #LP_ID #, #LP_NAME #, #CLASS_CAT_ID #"

I guess that CURR_CLASS_CAT_ID does not use the prefix P50_?

Andy

Tags: Database

Similar Questions

  • Join the query/right /.

    Join the query/right /.

    In the end, we try to find the ZZOMTAB. STAFF
    I know the value exists because I have asked this by
    K_NO
    By this query

    Select
    ZZOMTAB. STAFF
    Of
    ZZOMTAB
    where
    K_NO = 146735

    so that's where
    But what I'm left with app_no = 79219

    I tried this query and it does not work (no value in the ZZOMTAB. STAFF)
    SELECT
    ZZOMTAB. STAFF
    OF TKASERTAB
    ZZOMTAB RIGHT JOIN
    ON TKASERTAB. K_NO = ZZOMTAB. K_NO

    APPTAB RIGHT JOIN
    ON TKASERTAB.app_no = APPTAB.app_no

    where
    APPTAB.app_no = 79219


    the value that I'm trying to get is ZZOMTAB. STAFF
    and I give myself with app_no = 79219

    the tables are

    the tables are
    TKASERTAB with K_NO and APPNO columns
    APPTAB with column APPNO
    and
    ZZOMTAB with K_NO

    I'm trying to get the value of ZZOMTAB. STAFF
    Can anyone help?
    Thanks in adv


    Try to move the APPTAB.app_no = 79219 WHERE clause and put it in your RIGHT JOIN.

    SELECT
    ZZOMTAB. STAFF
    OF TKASERTAB
    ZZOMTAB RIGHT JOIN
    ON TKASERTAB. K_NO = ZZOMTAB. K_NO
    APPTAB RIGHT JOIN
    ON TKASERTAB.app_no = APPTAB.app_no
    AND APPTAB.app_no = 79219

    Another thread

    Phil

  • creating a dynamic list of values

    Hello

    While I am trying to create a dynamic list of values on a table (table1) with h_id columns, the head_foot and the header. I gave the query to create the dynamic values as list

    Select d, r header header
    of g.fw_header_footer
    order by 1

    where d is the display value and r is the return value to get the error message

    "1 error has occurred."

    LOV query is not valid, a display and a return value is needed, the column names must be different. If your query contains a query online, the first CLAUSE in the SQL statement must not belong to the query online. »


    Can someone please suggest me if am wrong.


    Thanks in advance

    Hello

    I suggest that you check the permissions of your application of the analysis of schema has on your g.fw_header_footer table.

    It is a mistake to mislead, but I've just reproduced the same problem trying to select from a table that I didn't have SELECT permission.

    Scott

  • Join the query - confused behavior

    Hello.. I need to make a join on four tables and select one data tables. The query is as below,

    SELECT THE VIRTUAL MACHINE. SEGMENT, VM.CA, VM. PR, VM. BP, VM. TERM_ID, VM. TL v_mlr_cable VM, v_neicode NEI, v_mlr MLR, v_fibre_ntwk_type FIBER WHERE MLR.master_key = 62 AND MLR.dslam_tid = NEI.id AND NEI.type = 'OLT' AND MLR.ntwk_type = FIBRE.id AND MLR.master_key = VM.master_key;

    This query works very well. I want to change the query to have an OR condition by combining certain conditions in the WHERE clause as below,

    SELECT THE VIRTUAL MACHINE. SEGMENT, VM.CA, VM. PR, VM. BP, VM. TERM_ID, VM. TL v_mlr_cable VM, v_neicode NEI, v_mlr MLR, v_fibre_ntwk_type FIBER WHERE MLR.master_key = 62 AND ((MLR.dslam_tid = NEI.id ET NEI.type = 'OLT') or MLR.ntwk_type = FIBRE.id) AND MLR.master_key = VM.master_key;

    This translates into several duplicates of the correct result lines (about 93 272 rows).
    I suspect this is a unwanted Cartesian product.
    I am limited to use a 'different' because my application performs custom, so 'distinct' query analysis is out of the option.

    I struggle to understand the result of this query. You can help... ! Thanks in advance.

    My database: Oracle Enterprise Edition 10.2.0.2.0

    Published by: vanessa on June 9, 2011 12:49 AM

    Hello

    Can hide you the SELECT DISTINCT in a subquery, like this:

    SELECT  *
    FROM    (
                SELECT DISTINCT  VM.SEGMENT, ...
            );
    

    or in a view?

    If this is not the case, use GROUP BY. The GROUP BY clause contains all the columns in the SELECT clause.

    You could also re - write the query to use EXISTS or IN, instead of a jon.
    For example:

    SELECT      SEGMENT
    ,     CA
    ,     PR
    ,     BP
    ,     TERM_ID
    ,     TL
    FROM     v_mlr_cable     vm
    WHERE     master_key     = 62
    AND     EXISTS (
              SELECT  0
              FROM     v_neicode       NEI
              ,     v_mlr            MLR
              ,      v_fibre_ntwk_type FIBRE
              WHERE     MLR.master_key      = vm.master_key
              AND      (     (     MLR.dslam_tid      = NEI.id
                        AND      NEI.type      = 'OLT'
                        )
                   OR      MLR.ntwk_type      = FIBRE.id
                   )
                )
    ;
    

    Do you think it is easier to read and understand the code formatted, as the query above, or unformatted, as what you posted?
    Who do you think will encourage people to read your question and provide accurate responses?
    Never write, not to mention NPA, not formatted.

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and INSERT, only relevant columns instructions) of all the tables and the results desired from these data.
    Explain how you get these results from these data.
    Always tell what version of Oracle you are using.

  • dynamic list of values

    Hello

    I need to create dynamic lov which must concatenate column name as first name and last name, but I am getting following error


    Select first_name. ' '|| last_name, 'name '.
    of oehr_Employees
    where name =: P8_FIRST_NAME
    order by 1

    error:

    LOV query is not valid, a display and a return value is needed, the column names must be different. If your query contains a query online, the first CLAUSE in the SQL statement must not belong to the query online.


    can you please help me?

    Try

    Select first_name. ' '|| display of last_name, first_name. ' '|| last_name return
    of oehr_Employees
    where name =: P8_FIRST_NAME
    order by 1

  • Dynamic lists of values - 2 different SQL query

    Hello

    I use dynamic values lists as mentioned below. This will return 2 different results depending on the conditions.
    This does not work, when I run the page, it gives a blank page to Popup when I click on the shortcut menu, it gives me error... * HTP 404 error *... web page not found

    P1_ITEM1 elements is of type - Popup LOV key (description of the poster, returns the key value)
    if :P1_ITEM1 = 'ABC' then
     return 'select ename d, empno r from emp';
    else
     return 'select dname d, deptno r from dept';
    end if;
    No idea why it does not work

    Thank you
    Deepak

    Published by: Deepak_J on January 27, 2010 19:31

    Published by: Deepak_J on January 27, 2010 19:32

    Published by: Deepak_J on January 27, 2010 19:32

    Hello

    I don't know why it does not work.

    But you can use this query LOV solution in this case

    SELECT ename d,
      empno r
    FROM emp
    WHERE :P1_ITEM1 = 'ABC'
    UNION
    SELECT dname d,
      deptno r
    FROM dept
    WHERE :P1_ITEM1 <> 'ABC' OR :P1_ITEM1 IS NULL
    

    BR, Jari

  • Join the query

    Hello

    I have two tables Employee and EmployeeDetail

    Employee table of data as follows:
    EmployeeID
    1
    2


    EmployeeDetail table of data as follows:
    EmployeeDetailID FkEmployeeID EmployeeName
    1 1 a
    2 2 b
    3 2 b1


    Note: that in the table EmployeeDetail, detail of the employee was inserted not updated therefore for EmployeeID: exiists there are 2 previous entry in the EmployeeDetail table.

    I want to take the latest recordings as
    EmployeeID EmployeeName
    1 a
    2 b1



    I tried following query
    Select Employee.EmployeeID, EmployeeDetail.EmployeeName of the employee
    Left Join EmployeeDetail
    where Employee.EmployeeID = EmployeeDetail.FkEmployeeID

    But he has a problem... I do not know how to choose the last disc

    last disk would probably be more EmployeeDetailID, base on this point, as an easy way:

    Select *
    From   Employee e, EmployeeDetail ed
    where e.employee_id = ed.employee_id
        And ed.EmployeeDetailID = (select Max(EmployeeDetailID ) from EmployeeDetail ed2 where ed2.employee_id = e.employee_id)
    

    best solution would be a rank of the analytic function on the partition by but it is more understandable.

    Published by: Mustafa KALAYCI on 05.Eki.2010 09:44

  • [Help] Join the query from 3 tables

    Hi, I'm new to database. I have a question about joining 3 tables, forgive me for my bad English.

    My paintings look like this

    Table 1: person (id, firstname, lastname)
    Table 2: AssignPersonAddress (id, personid, addressid, type)
    Table 3: address (id, phone, street, etc.)

    I need AssignPersonAddress table, because in my data structure, a person may have more than 1 address and address type must be registered (for example: private, work)


    I want to do a select query to the State any person with his private phone and work phone, like this.
    NOBODY | PRIVATE | WORK



    Right now my query looks like this
    select p.name , a1.tel AS Private, a2.tel AS Work
    from person p, 
    addresse a1 , 
    AssignPersonAddress apd1, 
    AssignPersonAddress  apd2, 
    addresse a2
    
    where p.id  = apd1.person (+)
    and apd1.adresse  = a1.id 
    and apd1.art = 'Private' 
    and p.objectid = apd2.person (+)
    and apd2.adresse  = a2.id 
    and apd2.art = 'Work'
    the problem is that I only get the person who has a private address and the job. But what I want is all anyone no matter if the person has only 1 or 2 address.

    As you can see I put the left outer join in where condition, but I always get the wrong result.


    THX in advance


    Danny

    Published by: raitodn on October 1st, 2009 03:51

    Published by: raitodn on October 1st, 2009 04:12
  • Display the list of values

    I created a page in a table with 3 elements. I wanted one of the items in a value list.

    Under the shared components, I created a dynamic list of value. I wanted now to fix the LOV on this element. For the page in question, I went to Page rendering-> items, but can not see all items created for this slot table form. Where did I select the item so that I can join the list of values.

    I read the day 2 + Application Express Developer's Guide and followed the example here.

    Thank you

    Hello

    On your page go to 'regions' and before the name you have given to this area, you can see a link that says "Report" click there and you can see all the items in the form of tables.

  • Table with list of value to load on another value of the column that is never changed by the user

    Nice day!

    I work with JDeveloper 11.1.2.4.

    I have a Table of the ADF that has 4 lines.  Each row has a column with a unique value.  The plan should include a LOV column in the row show a different list of values based on a single column value.  I have install the list of values, use a display with a variable binding criterion.  When you create the data LOV source, I Specifies the name of a single column for the value of the bind variable.  However, it seems that the LOV changes none selecting different lines.

    Is there a good way to handle this?  I did LOVs of person in charge in the past, but this isn't quite the same as the user can view only the value that depends on the LOV on.

    Any suggestions are greatly appreciated!


    BradW

    Hey, it's always a case of use of the dependent list of values. If the attribute that you bind the bind variable view criteria at part of the view object then the value LOV to be examined accordingly. I did a quick test case and I see my lists filtered by an attribute in line (I used the HR schema and posted employees as candidates managerId. The employee list is filtered so that it only shows the employees in the same Department that the employee I want to put a new managerId on) Frank

  • Create a list of values (Lov) programmatically

    I need to dynamically create the ListOfValues during execution.

    For this, I found a few links, in which it is explained how to create the ViewAccesor and the ListBindingDef which defined the Lov in the model project.

    Andrejus Baranovskis Blog: The ADF for BC and dynamic ADF ADF UI generator

    Binary: Activation for dynamic attributes ViewObject LOVs

    This kind of list of values can be rendered with the component, af:dynamicComponent, but I want to use them with the original component.

    The main problem is that: a dynamic list of values attributes do not have listOfValuesModel in the exposed binding.

    <af:inputListOfValues id="comunidadAutonomaId"
                                  popupTitle="Search and Select: #{bindings.ComunidadAutonoma.hints.label}"
                                  value="#{bindings.ComunidadAutonoma.inputValue}"
                                  label="#{bindings.ComunidadAutonoma.hints.label}"
                                  model="#{bindings.ComunidadAutonoma.listOfValuesModel}"
                                  required="#{bindings.ComunidadAutonoma.hints.mandatory}"
                                  columns="#{bindings.ComunidadAutonoma.hints.displayWidth}"
                                  shortDesc="#{bindings.ComunidadAutonoma.hints.tooltip}">
                <f:validator binding="#{bindings.ComunidadAutonoma.validator}"/>
            </af:inputListOfValues>
    

    Model = "#{Bindings.ComunidadAutonoma.listOfValuesModel}"-> This property is empty in an attribute with a dynamic lov, at the same time, it exists in a standard attribute with lovs. "

    I could check bindings exposed during this attributes are different too.

     <attributeValues IterBinding="ProvinciasIterator" id="ComunidadAutonoma">
          <AttrNames>
            <Item Value="ComunidadAutonoma"/>
          </AttrNames>
        </attributeValues>
        <listOfValues IterBinding="ProvinciasIterator" StaticList="false" Uses="LOV_Nombre" id="Nombre"/>
    

    To solve it, I thought that I could create the ListOfValuesModel of the ListBindingDef and the ViewAccesor dynamically exposed in a managed Bean, but I don't know how he.

    public class MyBean {
    
    
      public MyBean() {
        initListOfValuesModel();
      }
    
    
      private ListOfValuesModel listOfValuesModel;
    
    
      public ListOfValuesModel getListOfValuesModel() {
        return listOfValuesModel;
      }
    
    
      private void initListOfValuesModel() {    
        DCBindingContainer bindings = getBindings();
        JUCtrlValueBinding attrBinding = (JUCtrlValueBinding)bindings.get("myAttrib");
        ViewAttributeDefImpl attr = (ViewAttributeDefImpl) attrBinding.getAttributeDef();
        ViewDefImpl viewDef = attr.getViewDef();
        ArrayList<ListBindingDef> listBindings = viewDef.getListBindingDefs();
        ListBindingDef lbLov = null;
        for (ListBindingDef listBinding : listBindings) {
          if (listBinding.getListVOName().equals(attr.getLOVName())) {
            lbLov = listBinding;
            break;
          }
        } 
        ...
        //listOfValuesModel = ;
      }
    
    
    
    
    
    
    
    
    

    Another solution would be resolved in the code of the ad: dynamicComponent, because it could render the ListOfValues I programmatically add.

    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Code for adding programmatically to a lov

        private void buildLovVO(String voName, String voPath, String sql, Set<DataBindVar> bindVars, List<String> labels) {
            ViewDefImpl lovDef = new ViewDefImpl(voPath);
            lovDef.setBindingStyle(SQLBuilder.BINDING_STYLE_ORACLE_NAME);
            
            lovDef.setQuery(sql);
              
            lovDef.resolveDefObject();
            lovDef.registerDefObject();
            
            if (bindVars != null && bindVars.size() > 0) {
                VariableValueManager vvm = lovDef.ensureVariableManager();            
                for (DataBindVar bindVar : bindVars) {
                    VariableImpl lovBindVar = (VariableImpl)vvm.addVariable(bindVar.getBindVarName());
                    lovBindVar.setJavaType(bindVar.getBindVarType());
                    lovBindVar.setVariableKind(VariableImpl.VAR_KIND_WHERE_CLAUSE_PARAM);
                    lovBindVar.setProperty(AttributeHints.ATTRIBUTE_DISPLAY_HINT, AttributeHints.ATTRIBUTE_DISPLAY_HINT_HIDE);   
                }
            }
            
            if (labels != null && labels.size() > 0) {
                ViewObjectImpl lovVO = (ViewObjectImpl)app.createViewObject(voName, lovDef);
                for (int i = 0; i < labels.size(); i++) {
                    ((AttributeDefImpl)lovVO.getAttributeDefs()[i]).setProperty(AttributeHints.ATTRIBUTE_LABEL, labels.get(i));   
                }
            }
        }    
        
        
        private void buildListDef(ViewDefImpl dViewDefImpl, String viewAccessorName, String lovName, 
                                String listDataSourceViewDefName, Set<DataBindVar> bindVars, List<String> attribNames,
                                List<String> listAttribNames, List<String> listDisplayAttribNames) {
            ViewAccessorDef vdef = new ViewAccessorDef();
            vdef.setName(viewAccessorName); 
            vdef.setViewDefFullName(listDataSourceViewDefName);
            vdef.setRowLevelBinds(true);
            
            if (bindVars != null && bindVars.size() > 0) {
                for (DataBindVar bindVar : bindVars) {
                    vdef.getBoundParameters().addBoundParameter(bindVar.getBindVarName(), bindVar.getBindVarValue());
                }
            }
            dViewDefImpl.addViewAccessorDef(vdef);
            
            //---------PREPARAR STRING ARRAYS PARA LA FUNCION buildListBindingDef ------------//
            String[] strAttribNames = attribNames.toArray(new String[attribNames.size()]);
            String[] strListAttribNames = listAttribNames.toArray(new String[listAttribNames.size()]);
            String[] strListDisplayAttribNames = listDisplayAttribNames.toArray(new String[listDisplayAttribNames.size()]);
            
            ListBindingDef listBindingDef = buildListBindingDef(dViewDefImpl.getDefManager(), viewAccessorName, lovName,
                strAttribNames,
                strListAttribNames,
                strListDisplayAttribNames);
            dViewDefImpl.addListBindingDef(listBindingDef);  
        }
        
        private static ListBindingDef buildListBindingDef(DefinitionManager defMgr,
                                                         String listVOName,
                                                         String listBindingName,
                                                         String[] attribNames,
                                                         String[] listAttribNames,
                                                         String[] listDisplayAttribNames) {
            ListBindingDef lstbindingDef = new ListBindingDef(defMgr, DefinitionObject.DEF_SCOPE_PERS);
            lstbindingDef.setListVOName(listVOName);
            lstbindingDef.setName(listBindingName);
            lstbindingDef.setListRangeSize(-1);
            lstbindingDef.setNullValueFlag(AbstractListBinding.LIST_ADD_NULL_NOWHERE);
            lstbindingDef.setNullValueId("");
            lstbindingDef.setAttrNames(attribNames);
            lstbindingDef.setListDisplayAttrNames(listDisplayAttribNames);
            lstbindingDef.setListAttrNames(listAttribNames);
            
            return lstbindingDef;
        }
    

    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    JDeveloper 12 c (12.1.2.0.0)

    You can download code for ADF Rich Client Demo application (ADF Faces Rich Client Demos ) and see what the code is behind the af:inputListOfValues example (LOV in this example is populated by managed bean).

    If you need create liaison for lov programmatically, and then read this blog post: ADF practice: dynamic linking LOV

    Dario

  • How to get a prompt to return a list of values based on a prompt

    Hello
    In the link below, I show the chain and the guest of the station.
    The guest of the station must return a list of value based on the value I have insert for string.
    If for example I have insert FS for the Four Seasons chain, what resort it must return only the hotels belonging to four seasons.
    I tried as in the example with a variable, but not worked.
    Any idea?

    http://img163.imageshack.us/img163/4486/resortprompt.jpg

    Thanks and greetings
    Giuliano

    Hello

    Do you have values for the stations for the value of the selected channel. I assume that you have no station for the selcted string value values. Try to select values of chain of 5 or 10 and then check the value of the station. To force them to work there is no need to define any variable presentation.

    Kind regards
    Sandeep

    Published by: Teresa Sanchez on 10-Sep-2010 01:25

  • Check var PL/SQL in an if STATEMENT with a list of values returned by a SELECT?

    I have a variable in my PL/SQL code, and I want to check if the value of the var is in a list of values. This list of values I want to get directly from a select statement. I can do something like below:
    IF (v_var1 in (select col1 from <table> where <condition>))
    THEN
       <do something>
    ELSE
       <do something else>
    END IF;

    And rownum = v_loop will not work for rownum anything to 1.

    You can try something like:

    SELECT COUNT (1) INTO v_row_count FROM  WHERE ;
    
    IF (v_row_count = 0)
    THEN
       
    ELSE
       v_loop := 1;
       FOR I IN (SELECT col1 FROM 
    WHERE ) LOOP v_sel_val1 := I.col1; IF (v_var1 = v_sel_val1) THEN END IF; END LOOP;
  • 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

  • Attribute substitution does not not in the models of dynamic lists

    Hi all
    Dynamic lists were introduced at the APEX 4.1 and they can be used for drop-down menus. I try to use attribute substitution #A01 #... #A10 # in models without success.

    Here's a select sample

    < pre >
    SELECT the level,
    short_title label,
    ' f ? p = myapp:1:0:MYAPP_ID :'|| target ID,
    'NO' is_current
    NO picture,
    'm'|| Attribute1 to_char (ID)
    FROM MyTable
    START WITH parent_id =: MYAPP_ROOT_ID
    CONNECT BY PRIOR ID = parent_id
    Brothers and SŒURS of ORDER BY seq_in_parent
    < / pre >

    and here is a snippet of the model

    Model list associated

    & lt; class li = & quot; dhtmlMenuItem & quot; & gt; & lt; an id = & quot; #A01 #& quot; href = & quot; #LINK #& quot; & gt; # TEXT #& lt; /a & gt; & lt; /Li & gt;

    The substitution is not made. It looks like a bug, but maybe I'm missing something.

    Any help would be greatly appreciated.

    Regards Garry

    Hi Garry,

    Given the query you provided, it looks like you're missing two parameters in your query (marked as missing below):

     SELECT level,
            short_title label,
            'f?p=myapp:1:0::::MYAPP_ID:'||id target,
            'NO' is_current,
            NULL image,
            NULL image_attribute,                                 <----------- MISSING
            NULL image_alt_attribute,                             <----------- MISSING
            'm'||TO_CHAR(id) attribute1
       FROM mytable
      START WITH parent_id = :MYAPP_ROOT_ID
    CONNECT BY PRIOR id = parent_id
      ORDER SIBLINGS BY seq_in_parent
    

    Once you update your application, then if all goes well, you should see the correct replacement of the occurrences of #A01 # in the model of your list with the value returned by the query to youe.

    Kind regards
    Hilary

  • Maybe you are looking for