Order BY with ROWNUM in Select List

Hi,
I have query like bellow for Oracle 11g:
create table em_c (vl_s_ec int,id_em_em int,id_empcre_ecr int, id_em_ec int);
create table em (id_em_em int)
Select e.id_em_em
, NVL(
(SELECT * FROM(SELECT a.vl_s_ec FROM em_c a WHERE a.id_em_em = ec.id_em_em
AND a.id_empcre_ecr < ec.id_em_ec order by a.id_em_ec DESC) WHERE ROWNUM <= 1) ,0) AS col2
FROM em_c ec
INNER JOIN em e on ec.id_em_em = e.id_em_em
WHERE 1 = 1;
But inner subselect doesn't see table "em_c ec" from outer FROM clause. That's why following error occurs:
SQL Error: ORA-00904: "EC"."ID_EM_EC": invalid identifier
Please help me to make it work.
Edited by: user11290901 on Dec 17, 2010 2:11 AM

Correlation names only go one level deep. It's a bit tough to decipher your query so if you want a better response please post the following:
1. Oracle version (SELECT * FROM V$VERSION)
2. Sample data in the form of CREATE / INSERT statements.
3. Expected output
4. Explanation of expected output (A.K.A. "business logic")
5. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • ORDER BY using a Non-SELECT list column

    I need to SELECT DISTINCT values from a column and ORDER it by another column in the same table which is not in the SELECT list. When i got
    ORA-01791: not a SELECTed expression error, I tried various things like putting ORDER BY clause in the outer query, using a DISTINCT in the ORDER BY clause,..etc but couldn't succeed.
    SQL> create table sample_table (col1 number, col2 number);
    Table created.
    SQL> select distinct(col1)
      2  from sample_table
      3  order by col2;
    order by col2
    ERROR at line 3:
    ORA-01791: not a SELECTed expression
    SQL> select col1 from
      2  (select distinct(col1) col1 from sample_table)
      3  order by col2;
    order by col2
    ERROR at line 3:
    ORA-00904: "COL2": invalid identifier
    SQL> select distinct(col1) col1 from sample_table
      2  order by distinct(col2);
    order by distinct(col2)
    ERROR at line 2:
    ORA-00936: missing expressionAny workarounds for this seemingly simple requirement?

    Any workarounds for this seemingly simple requirement?This is not a simple requirement. It is a self contradictory requirement.
    You want to order an result on a attribute that you don't have. This is not possible from a logical point of view.
    Like saying,
    "I want the typical/distinct family size in houses in my town, ordered by house number."

  • Need a little JavaScript help with disabling a select list in a tabular frm

    Hello Folks
    Here's the scenario.
    I have a tabular form which, subject to the setting of one Select List, I want to disable/enable another.
    I have got this far and it will disable a text item but not a select list..
    This is in the HTML header section for the page...
    <script type="text/javascript">
    function test(pThis)
    var currIndex = $('select[name="'+pThis.name+'"]').index(pThis);
    if (pThis.value=='2') {
    $('input[name="f02"]')[currIndex].style.backgroundColor = "LightGrey";
    $('input[name="f02"]')[currIndex].disabled=true;
    The report region is defined as...
    SELECT apex_item.text(1, ir.iot_rebate_type_id) iot_rebate_type_id
    ,apex_item.select_list_from_lov_xl(2,ir.rebate_currency,'LOV_CURRENCY_CODES') rebate_currency
    FROM iot_rebate ir
    WHERE ir.iot_agreement_id = :P303_IOT_AGREEMENT_ID
    The iot_rebate_type_id column has an Column Element Attribute set to...
    onchange="javascript:test(this);"
    As I say, if I define the rebate currency as a text item, the javascript works fine.
    Can anyone offer any suggestions?
    Many thanks
    Simon
    Application Express 4.0.2.00.07

    Simon Gadd wrote:
    Hi Vikram.
    That's great.
    I have the relevant items being set to diabled & grey (and also the reverse of this if the driving select list is changed back).
    As this is being used in a Tabular form, if I am calling pre-existing records which should be displayed with two of the select lists disabled, can you point me in the right direction to show the relevent select lists as disabled when the records are returned from the database?If you are using apex_item API set the disabled property into p_attributes parameter conditionally using a case statement in you sql statement
    Another option is you can use some javascript to loop through the tabular form array that runs on the onload of the page.
    Finally, if some columns are disabled, this invaludates the MRU process on the page. Is there a way to submit the page with some fields in the disabled state?Do that as per Roel's suggestion for this issue.
    Any input/pointers much appreciated.
    Simon

  • Tabular form with select list not updating

    I have created a tabular form with a dynamic select list
    select primary_key, column1,
    htmldb_item.select_list_from_query(10,column2, 'select descr d, column_value r from lookup_table where column_value = '||column1) column2
    from main_table
    The select list appears to work correctly but the new value is not saved to the database. I assume this is because the tabular form element display as field for column2 is set to "standard report column" but when I select any of the "display as text" or "LOV" options either the current data is not displayed or errors are generated.
    Any suggestions?
    Thanks,
    Bob

    Hi Ian,
    As you have seen, sorting on the project_manager_id column will sort by the id value rather than the textual value. This is, of course, because this is the value in the field.
    I haven't tried this out, but one thing that may work is the fact that you don't have to include the ORDER BY fields within the SELECT statement. You could, for example, do:
    select p.project_number, p.project_manager_id
    from projects p, users u
    where p.project_manager_id = u.id (+)
    order by u.name
    Obviously, you won't be able to do this in the existing statement as you would then be blocked from using column sorting. However, it implies that if you could construct the SQL statement dynamically, appending appropriate ORDER BY strings to the end of the base select statement, you could sort by anything you like. This does, of course, mean that you would have to create a mechanism to allow the user to select the sort order, generate the appropriate string and reconstruct the entire sql statement.
    I had had a similar request quite a while ago. The underlying reason for that request turned out to be that the user just wanted to quickly locate records relating to one person. In the end, we agreed that a search filter was the best thing to do.
    Regards
    Andy

  • Reset Select List in Form With Report

    Hi,
    i have Created Form with Report Page. I have three select List on this page.
    1-Market Name Select List with Redirect
    2-Customer Name Select List with Redirect
    3-Contect Person
    when i select market Name then Respective Customer name is select In to select List Customer Name.
    When i select Customer Name Then Contact Person is Select in Select List Contect Person.
    Problem is when i select Customer Name from Select List then Contact Person comes into Contact persion Select List But the value in select List Customer Name and Market Name is not dispaly , Display Only -Select Market - and -Select Customer Name- .
    I want when i select Customer NAme From Select List then value from MArket and customer Select List should not be reset.
    How can i do this.
    Thanks
    Edited by: 805629 on Jan 26, 2011 10:45 PM

    Try 'select list with submit', not "select list with redirect". Redirect usually doesn't save the values in session state so they are lost when the page repaints.

  • Sales order create with reference to contract order

    Hi,
            I am trying to create a sales order with reference to an
    existing contract order. I have given the contract order and clicked on the selection-list button to select the items I want to copy. It listed the items, but I am not getting all the details of the item. Material description (VBAP-ARKTX) is not coming.
    Is it related to config? This is happening in my quality system where as in my development system, I could see the material
    shorttext appearing.
    Please let me know how to proceed.
    Thanks & Regards,
    Vishnu Priya

    hi,
    please check if there are any missing transports between Development and quality. and also check if there are any customizations done either to bring them or prevent on any specific conditions. Also check if all the required master data is maintianed correctly.
    regards
    sadhu kishore

  • URG: ORACLE ERROR 6502 IN FDPSTP IN PICK SELECTION LIST GENERATION

    Dear All,
    I'm on 11.5.7 on Linux.
    My problem is with WSHPSGL: Pick Selection List Generation that ends with error when launched from transactions form.
    The program end with the following error:
    Oracle Shipping: Version : 11.5.0 - Development
    Copyright (c) 1979, 1999, Oracle Corporation. All rights reserved.
    WSHPSGL module: Pick Selection List Generation
    Current system time is 14-NOV-2002 11:26:13
    **Starts**14-NOV-2002 11:26:14
    ORACLE error 6502 in FDPSTP
    Cause: FDPSTP failed due to ORA-06502: PL/SQL: numeric or value error:
    character to number conversion error
    ORA-06512: at line 1
    If we launch the report trough OM Superuser - Shipping - Release Sales Orders -
    Release Sales Orders, there's no error.
    Has anyone have this kind of error? How can we solve it?
    Any help would be greatly appreciated.
    Thanks in advance
    FG

    EBS is 11.5.10.2
    OS is OEL 5.3.
    It was running fine until yesterday.But its giving error today.
    error log shows exception in Release_Batch_SRS procedure.
    exact code is ---
    ++++++++++++++++++++++++
    IF G_CONC_REQ = FND_API.G_TRUE THEN
    l_ret_code := FND_CONCURRENT.SET_COMPLETION_STATUS('ERROR','');
    errbuf := 'Exception occurred in Release_Batch_SRS';
    retcode := '2';
    END IF;
    ++++++++++++++++++++++
    Thanks,
    Rakesh

  • Positioning/Sorting in Selection list while Refrencing in VA01

    Hi!
    When using VA01 with reference, on Selection list I want to find / position cursor on all items with certain material but program positions me only on first.
    Is it somehow possible to go on next item with entered material or  is it possible to sort items by materials on selection screen?
    Regards,
    Ante

    Hello Godhuli,
    Thanks for the reply, actually that sorting option change the sorting order in the result (i.e on the grid which is displayed when query is actually executed).
    My question was when i have some selection criteria for some variables in a report and on the first screen a list of all those variables appear where i can select or write down the filter values. there i have the option to click so a new small window popsup which shows me the some possible values of that variable and i select from that (based in =,[],* etc....). I want value in that Pop Up window to be sorted on text and by default those values are sorted on "Keys"[ and even in my query properties-> Display options, i have only selected to show "text" and to sort on that in ascending order] so it seems that those options are not governing what i want to change.
    Thanks in advance for your help.
    Regards
    Akshat

  • Select list null value issue - for filtering the tabular form report

    hello,
    I have a tabular form created on emp table and in the table their are entries for the employees who don't have a location, like it is null for some of the employees.
    Now I have created a select list item - for filtering the results based on location.
    my select query for select list item is
    select distinct location_name d,location_id r from emp order by 1
    -- so my select list contains all the distinct location_name including the null on my tabular form.
    so based on the selelcted value(in the select list), I am able to filter the results in my tabular form.
    but the thing is that when i try to select an null value from my select list - i am not able to filter my report - like its displaying all the records, its not filtering.
    can anyone help me out with this.
    thanks.

    Hi
    Try below select for LOV
    select distinct nvl(location_name,'No Location') d,nvl(location_name,'No Location') r from emp order by 1 And then change tabular from select where clause also use nvl(location_name,'No Location') like
    SELECT *
    FROM emp
    WHERE nvl(location_name,'No Location') = :Px_YOUR_ITEMBr, Jari

  • How to submit a multiple-selection list box in an Infopath Sharepoint form as multiple entries on a Sharepoint list?

    I would like to be able to submit an Infopath form with a multiple selection list box in Sharepoint as multiple entries on a Sharepoint list.
    For example, a user has to complete the following fields:
    First Name:
    Last Name:
    Favorite Color (can select more than one):
    [] Blue
    [] Red
    [] Yellow
    [] Green
    If the user picks blue AND red and submits the form, the Sharepoint list would feature TWO entries, both with their first and last names, but with different colors in the "Favorite Color" column.
    Please let me know if there is a way to do this. Any guidance would be helpful!

    Hi redhotc,
    According to your description, my understanding is that you want to set multiple default values for a multiple checkbox list in InfoPath form.
    I did a test with SQL database table. I set three default values for the checkbox list by adding three values field under the group field(Data->Default values), each value field is for a default value. Then publish it to my SharePoint site, everything
    was fine.Please have a try as the below link:
    http://www.bizsupportonline.net/infopath2010/pre-select-items-multiple-selection-list-box-infopath-2010.htm
    Note: if you are using SQL databse table, you may need to enable ‘Allow cross-domain data access for user form templates that use connection settings in a data connection file’ in CA. More information, please refer to:
    http://answers.flyppdevportal.com/categories/sharepoint2010/sharepoint2010customization.aspx?ID=418b9423-a96c-4e5e-91f9-6a1b010ebb69
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • Select lists, Static Assignment Computations

    Hi,
    I'm using ApEx 4.0.1 on Windows XP Pro SP3.
    I need to set items default values when the page loads.
    So I created "Before Header" computations for each item (static assignment).
    When I run the page, the default values are set, but for select lists I need to change the selected value too, not only the returned value.
    (for example for a select list containing values (1,2,3,4,5) with a default value of 1. If I select 3, and then reload the page, the selected value is still 3 but the returned value will be 1.)
    Is there a way to set the selected value at the same time, without having to create a special process to do that ?
    Thank you.
    Yann.

    Sorry Denes for this late reply, I was working on an urgent thing.
    So, I tried to export the application on apex.oracle.com but I can't make it run as it uses a lot of procedures/functions, packages, etc... and I don't have time to create again all the databases objects on apex.oracle.com.
    So you can access the application but you will get an error if you try to run it.
    Login : temp_user
    Password : temp_pass
    Application : 17706 - Géode2010
    Page : Page 3 - Points
    I tried to created on other test page with only 2 select lists (Application : 20588 - Géode, Page : 2 - Filter) , and it works...
    So I think the cause of the problem is somewhere else on the page.
    If you have time to take a look let me know.
    Thanks.
    Yann.

  • JavaScript Radiogroup/Select List

    Hi,
    I would to multiple the values of a radiogroup and a select list.
    This is what I have so far:
    <script type="text/javascript">
      function sumItems(){
        function getVal(item){
       if(document.getElementById(item).value != "")
         return parseFloat(document.getElementById(item).value);
       else
         return 0;
        document.getElementById('P1_TOTAL').value =
           getVal('P1_RADIO') * getVal('P1_SELECT');
    </script>
    I get a NaN error; I assume that is because of the radiogroup and/or select list.
    Is this a correct assumption?
    Thanks
    VC

    Hello,
    The following is a very simple example of the technique I offered you - http://apex.oracle.com/pls/apexbeta/f?p=10:30 . You can adapt it to any specific select lists you are using, and to any number of them.
    I defined 3 hidden items on the page:
    - P30_ORIGINAL – holds the original value of the select list
    - P30_FLAG0 – set to ‘true’ if a select list value set to 0. Init value 'false'
    - P30_FLAG2 – set to ‘true’ if a select list value set to 2. Init value 'false'
    The following is the JavaScript code:
    <script type="text/javascript">
    function saveOriginalValue(pItem){
      $x('P30_ORIGINAL').value = pItem.value;
    function validate_Selected_Value(pItem){
      if ($x('P30_ORIGINAL').value == 0 && pItem.value != 0) {
        $x('P30_FLAG0').value = 'false';
      if ($x('P30_ORIGINAL').value == 2 && pItem.value != 2) {
        $x('P30_FLAG2').value = 'false';
      if (pItem.value == 0) {
        if ($x('P30_FLAG0').value == 'true'){
          alert("You can't choose 0 as a value");
          pItem.value = '%';
          return;
        $x('P30_FLAG0').value = 'true';
      if (pItem.value == 2) {
        if ($x('P30_FLAG2').value == 'true'){
          alert("You can't choose 2 as a value");
          pItem.value = '%';
          return;
        $x('P30_FLAG2').value = 'true';
    </script>For each select list item I’m using the following events (in the ‘HTML Form Element Attributes’ field):
    onfocus="saveOriginalValue(this)" onchange="validate_Selected_Value(this);"As you can see, this code is generic, so you can use it with as many select lists you need on your page.
    Regards,
    Arie.

  • Inserting multiple rows into a table using a multiple-select list

    I'm trying to figure out how to take the output of a multiple-select list (":" separated list of values) and use that to update a table by inserting multiple rows based on the values. Is there a straight-forward way to do that in APEX?
    Thanks.
    Chris

    Hi Chris,
    I think this should give you what you need: Working with a Multiple Select List Item
    --Jennifer                                                                                                                                                                                                                                                                                                                                                                                                   

  • Create a select list using AJAX

    Hello,
    I saw Carl Backstrom and Scott Spendolini examples on how to use AJAX to populate a related item, based on a select list. What I'm looking for is the reversed angle.
    I have a TextItem, and I want to generate a select list based on that TextItem, something like this:
    select code, desc
    from Table
    where code like TextItem
    Is it possible with AJAX? (in the current examples I gat lost in the on demand application process – How, if possible, to render the select list using the HTP package.)
    Greatly appreciate the help
    Arie.

    Carl,
    I hope you can help with this, from reading the forum, you seem to have a lot of experience with AJAX and Application Express. I have found your examples within the forums and can not get them to work on my servers. I am on version 2, and a 10g database. I am attempting to place 4 select lists on a page. Each one (with exception from the first) will be dependent on the previous. To make is simple I have started with only 2 select lists. The first select list (p1_select1) is a list of departments. The second list (p1_select2) should populate with the users who belong to the department selected from p1_select1. I can not seem to get the second select list to load. I have attempted to follow your code as best I could, I can see on the page that it has created the xml data, however it just does not populate the second select list. Here is a summary of what I have.
    Thanks for lookin.
    Mike
    Page Regions:
    HTML: main (10)
    Region Header:
    <script language="JavaScript1.1" type="text/javascript">
    function f_Get_Data(pThis,pSelect_Source,pSelect_Target){
    var l_Return = null;
    var l_Select = html_GetElement(pSelect_Target);
    var get = new htmldb_Get(null,html_GetElement('pFlowId').value,'APPLICATION_PROCESS=Get_Data',0);
    get.add(pSelect_Source,pThis.value);
    gReturn = get.get('XML');
    if(gReturn && l_Select){
    var l_Count = gReturn.getElementsByTagName("option").length;
    l_Select.length = 0;
    for(var i=0;i<l_Count;i++){
    var l_Opt_Xml = gReturn.getElementsByTagName("option");
    appendToSelect(l_Select, l_Opt_Xml.getAttribute('value'), l_Opt_Xml.firstChild.nodeValue)
    get = null;
    function appendToSelect(pSelect, pValue, pContent) {
    var l_Opt = document.createElement("option");
    l_Opt.value = pValue;
    if(document.all){/* why is ie different ask bill */
    pSelect.options.add(l_Opt);
    l_Opt.innerText = pContent;
    }else{
    l_Opt.appendChild(document.createTextNode(pContent));
    pSelect.appendChild(l_Opt);
    </script>
    Items
    Region: main
    10: P1_TEXT1 Select List
    20: P1_TEXT2 Select List
    P1_TEXT1 Form Element:
    onChange="javascript:f_Get_Data(this,'P1_TEXT1','P2_TEXT2')";
    APPLICATION PROCESS "On Demand" Get_Data:
    declare
    begin
    owa_util.mime_header('text/xml', FALSE );
    htp.p('Cache-Control: no-cache');
    htp.p('Pragma: no-cache');
    owa_util.http_header_close;
    htp.prn('<select>');
    for rec in (select ENAME , EMPNO
    from EMP where DEPTNO = :P1_text1) loop
    htp.prn('<option value="' || rec.EMPNO || '">' || rec.ENAME || '</option>');
    end loop;
    htp.prn('</select>');
    exception
    when no_data_Found then
    null;
    end;

  • Multiple-Selection List Box Values in Multiple Columns

    I am using InfoPath 2010 with SharePoint 2013. I have a form with a multiple-selection list box which has A LOT of choices. Instead of displaying all the choices in one column, is it possible to display the values of my list box in several
    columns? 

    Hi Andrea,
    I agree with Brij, one multiple-selection list box is associated with one list field, we cannot use the one multiple selection list box value for other multiple selection list boxes, we need to create multiple choices for each multiple-selection list box
    control in InfoPath form.
    Thanks
    Daniel Yang
    TechNet Community Support

Maybe you are looking for