LOV Query is "invalid" all of a sudden...

The query below was written a while back (I've been through several APEX upgrades since then). I recently went in to the LOV Definition to make some changes and found that, no matter what I do, I get the error:
"LOV query is invalid, a display and a return value are needed, the column names need to be different..."
This is even true if I make no changes to the Query but try to "Apply Changes". I'm guessing that an upgrade someplace along the line is causing this.
Any ideas on how to make this query valid once again?
(APEX 3.1)
Thanks!
Alex
SELECT 'ES Value of ' || TO_CHAR(round(ve_value,-2),'$99,999,999') d, 'ES' c
FROM QUERY_MAIN qm
WHERE query_id = nv('P310_QUERY_ID')
AND subject_propid = nv('P309_BLS_PROPID')
AND nvl(ve_value,0) > 0
UNION
SELECT 'PV Value of ' || TO_CHAR(round(Bluelime_Common.get_perfect_value(nv('P309_BLS_PROPID'), NULL, NULL, TO_DATE(:p0_base_date, 'MM/DD/YYYY')),-2),'$99,999,999') d, 'PV'
FROM dual
where TO_DATE(:p0_base_date, 'MM/DD/YYYY') != trunc(sysdate)
UNION
SELECT 'PV Value of ' || TO_CHAR(round(Bluelime_Common.get_perfect_value(nv('P309_BLS_PROPID')),-2),'$99,999,999') d, 'PV'
FROM dual
where TO_DATE(:p0_base_date, 'MM/DD/YYYY') = trunc(sysdate)
or :p0_base_date is null

Have you tried this:
SELECT disp_val d, ret_val r
  FROM (SELECT    'ES Value of '
               || TO_CHAR (ROUND (ve_value, -2), '$99,999,999') disp_val,
               'ES' ret_val
          FROM query_main qm
         WHERE query_id = nv ('P310_QUERY_ID')
           AND subject_propid = nv ('P309_BLS_PROPID')
           AND NVL (ve_value, 0) > 0
        UNION
        SELECT    'PV Value of '
               || TO_CHAR
                     (ROUND
                         (bluelime_common.get_perfect_value
                                                       (nv ('P309_BLS_PROPID'),
                                                        NULL,
                                                        NULL,
                                                        TO_DATE
                                                               (:p0_base_date,
                                                                'MM/DD/YYYY'
                          -2
                      '$99,999,999'
                     ) disp_val,
               'PV' ret_val
          FROM DUAL
         WHERE TO_DATE (:p0_base_date, 'MM/DD/YYYY') != TRUNC (SYSDATE)
        UNION
        SELECT    'PV Value of '
               || TO_CHAR
                     (ROUND
                         (bluelime_common.get_perfect_value
                                                        (nv ('P309_BLS_PROPID')
                          -2
                      '$99,999,999'
                     ) disp_val,
               'PV' ret_val
          FROM DUAL
         WHERE TO_DATE (:p0_base_date, 'MM/DD/YYYY') = TRUNC (SYSDATE)
            OR :p0_base_date IS NULL)Denes Kubicek
http://deneskubicek.blogspot.com/
http://www.opal-consulting.de/training
http://htmldb.oracle.com/pls/otn/f?p=31517:1
-------------------------------------------------------------------

Similar Messages

  • Select list and subquery: "LOV query is invalid"

    Hi all,
    I want to create a select list with the following format:
    "name1 (count of another table)"
    "name2 (count of another table)"
    I've boiled it down to a simple query with a non-correlated subquery that works fine in SQL*Plus but not as an LOV:
    select table1.field1 || (select count(*) from table2) d,
    table1.field2 r
    from table1
    I get this (Apex 3.2.1):
    1 error has occurred
    * LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query.
    Even this doesn't work:
    select table1.field1 || (select 'a' from dual) d,
    table1.field2 r
    from table1
    I've tried it with an inline view, joining table1 to a select from table2 that returns the count, but I get the same result. Any ideas?
    Edited by: MalcA on Jan 22, 2010 12:14 PM

    I don't know, but the difference is that the count(*) code goes from the select clause to the from clause.
    Other times I had the same problem and always did it and it was the solution.

  • LOV query is invalid, a display and a return value are needed

    hello - i am having this issue and can't get around this when creating a popup LOV based on sql.
    below is LOV query. as you see the view has only two columns. I tried various ways by giving alias to columns in query but nothing works. What did I miss here?
    select description,inventory_item_id from xx_apex_inv_v
    1 error has occurred
    LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query.

    Did you try it like this?
    select description d, inventory_item_id v from xx_apex_inv_v

  • LOV Query is Invalid

    When testing the following in SQL Commands it runs.
    select DISTINCT LNAME, FNAME as display_value, FNAME||' '|| LNAME as return_value
    from PERSONNEL_SSN
    where ACTIVE = 'Y'
    order by 1
    However, I get an LOV Query is Invalid error when trying to use it in Source: Lists of Values Query.
    I'm new to Apex and am learning as I go.
    Any suggestions would help.
    Thanks!

    As Marc advised, you are returning an additional field, although I suspect you are maybe attempting to display "Last Name, First Name" - if so, you would do this:
      select distinct lname||', '||fname display_value
           ,fname||' '||lname return_value
      from personnel_ssn
    where active = 'Y'
        order by 1Having said that, you might want to re-visit your data model - you might come unstuck if new employee "Michael R. O'Donnell Esq." joins the organisation on the first day of your holiday... :-)
    Edited by: Joel_C on 16-Nov-2011 15:42

  • LOV query is invalid, a display and a return value are needed, the column n

    Hello,
    I used to have no trouble at all creating dynamic LOV but from today I' am alway getting the error mentioned above.
    This is the LOV query
    select nm,zon_id from scr_zones_mv@d29ut
    I tried to created a view of the referenced table, I'm able to select from this view in query builder but it gives the same error.
    What is going wrong?
    Erwin

    Sorry guys,
    I already found the problem.
    thanks
    Erwin

  • LOV Query Invalid

    Hello.
    I am uisng Apex 4.1 on Oracle 10.2.0.5 and Oracle App Server.
    Would someone please tell me why the following LOV query is causing the dreaded error:
    LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query.
    select d, r
    from
    select
    '(select)' as d,
    'javascript:void(0)' as r
    from dual
    union
    select
    initcap(INFO_NAME) as d,
    'javascript:popUp2(''' || INFO_LINK || ''', 1000, 800);' as r
    from INFO_LINKS
    order by 1Running this query in the SQL Commands section returns the result set without problem.
    Related to this, I've noticed that I am getting this same error for many similar LOV "complex" queries that involve things like UNIONs or sub-queries. In fact, when I bring up an already working LOV query in the LOV editor and then simply click the "OK" button without modifying the query, I get this same error. WHY?
    Thanks in advance for any help on this.
    Elie

    Hello Everyone.
    I just realized what my mistake is.
    Many of the individual lines in my LOV query are ending with a carriage-return character. And so, the following code line is literally concantonated with the previous line.
    Once I added one or more space characters to the end of each code line, Apex accepted the query without problem.
    Whew! That was tricky, indeed.
    And this is why many of my other already working queries suddenly caused the error when I clcik the OK button in the LOV editor. For some reason, bringing up these already existing, working queries stripped awawy any space characters from the very end of the code codes.
    I hope this helps others facing the same issue.
    Elie

  • Invalid LOV query error

    I am trying to modify a query for LOV page item but get an Invalid LOV query error when trying to Apply Changes to my page(query however works in SQL*Plus)
    I am trying to change the date format of query result to MON YYYY.
    Original query that works:
    select distinct bill.BILLED_DATE display_value, bill.BILL_ID return_value
    from BILL;
    New Query that fails in APEX (but works in SQL*Plus)
    select distinct to_char(bill.BILLED_DATE, 'MON YYYY') display_value,
    bill.BILL_ID return_value from BILL;
    Anyone have any idea what I need to do to make this work?
    "1 error has occurred
    LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query"

    Strange, this lov does work and is no different than yours:
    select distinct to_char(sysdate,'MON YYYY') disp, 1 retval from dual
    What are the results from the query? Can there be something wrong with that?
    Regards Guido

  • 1.6 LOV query invalid, was working in 1.5

    The following LOV query was valid in 1.5:
    select rd.name, rd.refdata_id from refdata rd, refdata_meta meta where meta.name = 'Title' and rd.refdata_meta_id = meta.refdata_meta_id and (:20_PATIENT_ID IS NOT NULL OR visible = 'Y') order by rank
    This query is being flagged as invalid in 1.6. The problem appears to be the parenthetical OR clause, since taking it out passes validation. The error message is:
    "LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query."
    Seems to me that the validator is equating the existence of a left parenthesis with an inline query, which of course is incorrect as the above perfectly valid SQL demonstrates.
    The query with the OR clause operates to populate the LOVs just fine in my existing app migrated from 1.5, so this is a maintenance and new app creation issue.
    I can of course work around it by views as needed to support a simplified LOV query, but I would much rather just get the former level of functionality back. Any prospect of fixing what appears to me to be a bug in the LOV query validator for the 1.6 platform?
    thanks,
    susan weber

    Susan,
    In 1.6, we introduced LOV query validations, to help head off problems before runtime. Looks like in this case, the check has a bug. It's trying to parse your SQL as if it were a query in a region and it fails because of the item name you are using that begins with a numeric digit and is followed by non-numeric characters. Such a query fails to parse with DBMS_SQL.PARSE. But the query does work, as you know, in an LOV, where EXECUTE IMMEDIATE with a USING clause handles it okay.
    So we have three bugs, the LOV query validation algorithm, the misleading validation failure message, and the bug that allows users to create and use items with names that are not valid Oracle identifiers. Thanks for pointing this out.
    Your workaround is to use v('20_PATIENT_ID') instead of using bind variable notation.
    Scott

  • Can someone tell me what's wrong with this LOV query please?

    This query works fine..
    select FILTER_NAME display_value, FILTER_ID return_value
    from OTMGUI_FILTER where username = 'ADAM'
    But this one..
    select FILTER_NAME display_value, FILTER_ID return_value
    from OTMGUI_FILTER where username = apex_application.g_user
    Gives the following error.
    1 error has occurred
    * LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query.
    Thanks very much,
    -Adam vonNieda

    Ya know, I still don't know what's wrong with this.
    declare
    l_val varchar2(100) := nvl(apex_application.g_user,'ADAM');
    begin
    return 'select filter_name display_value, filter_id return_value
    from otmgui_filter where username = '''|| l_val || '''';
    end;
    Gets the same error as above. All I'm trying to do is create a dropdown LOV which selects based on the apex_application.g_user.
    What am I missing here?
    Thanks,
    -Adam

  • LOV Query with decode

    Hi All,
    I have following Query for my LOV.
    SELECT DECODE (PTY_COMP_FLG, 1, PTY_COMP_E_NAME,
    PTY_E_FIRST_NAME || ' ' || PTY_E_LAST_NAME)
    PTY_NAME,
    PTY_NUM
    FROM RE_PARTY
    WHERE PTY_TYPE = 1
    ORDER BY 1
    I get the following error.
    LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query.
    Please help me out of this.
    Thanks in advance.
    Regards
    Arif
    Message was edited by:
    Arif

    Check the query once again, as it should work.
    Ex:
    SELECT DECODE (EMPNO,2839,ENAME,JOB||' '||'NO MANAGER') Display_Value,
    EMPNO Return_Value
    FROM EMP
    WHERE JOB <> 'MANAGER'
    ORDER BY 1
    Its just a query tried in LOV and it is working.
    Regards
    Ckengs

  • Trouble using pipelined function in an select list lov query

    I'm trying to use a pipelined function in a select list lov query but i cet the error
    "LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query."
    my query is as follows :
    SELECT gt.navn d, gt.GEOGRAPHY_TYPE_ID r
    FROM GEOGRAPHY_TYPE gt
    WHERE gt.kode NOT IN (1)
    and gt.kode in (select lov_value from table(RAPPORT_FILTER_PKG.GET_RAPPORT_FILTER_VALUE_PIP (
    SYS_CONTEXT ('rapport_filter_ctx','filter_id'),'GEOGRAPHY_TYPES')) )
    ORDER BY gt.navn DESC
    if i use a discrete values '80' instead of the call to
    SYS_CONTEXT ('rapport_filter_ctx','filter_id')
    i don't get eny errors, but then the LOV isn't as dynamic as i has to be
    any idears???
    Edited by: [email protected] on Dec 1, 2008 8:50 AM
    Edited by: [email protected] on Dec 1, 2008 11:17 AM

    nope that doesn't do it either
    contains a syntax errror at
    SYS_CONTEXT (('rapport_filter_ctx',:P500_RAPPORT_FILTER_ID),'GEOGRAPHY_TYPES'))
    my theory is that it's got something to do with the way APEX binds values because
    the query
    SELECT gt.navn d, gt.GEOGRAPHY_TYPE_ID r
    FROM GEOGRAPHY_TYPE gt
    WHERE gt.kode NOT IN (1)
    and gt.kode in (select r from table(RAPPORT_FILTER_PKG.GET_RAPPORT_FILTER_VALUE_PIP ('80','GEOGRAPHY_TYPES')) )
    ORDER BY gt.navn DESC
    works fine in both TOAD and in APEX but as soon as i replace th '80' with :P500_RAPPORT_FILTER_ID then, apex won't accept the code??????
    Edited by: [email protected] on Dec 3, 2008 7:54 AM

  • LOV query first||last

    I want to create a LOV query that concats the lastname firstname and then returns emp# as the key.
    How do I embed it in such a way to make this happen.
    I used the following but get an error:
    select last_nm ||' '|| first_nm, Employee_nbr from hr.v_keys_employee@dwprod order by 1
    The error is: LOV query is invalid, a display and a return value are needed, the column names need to be different.

    I am doing the same thing. I want only employees of a certain type so I want to join on another table. It took forever to get the syntax just right but this works:
    select fac_contacts.txtlastname ||', '|| fac_contacts.txtfirstname emp_name,
    fac_contacts.id return
    from fac_contacts, fac_lk_contact_types
    where fac_contacts.contacttypeid=fac_lk_contact_types.id
    and fac_lk_contact_types.txtname='Facilities'
    order by 1

  • "FROM" in a string in a LOV query

    An LOV query such as this:
    select c001 || ' from '  d, seq_id r
    from   apex_collections
    where  collection_name = 'ABC'
    order by 1produces this error when trying to save the LOV: "LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query."
    Splitting the string into two pieces (e.g., ' fr' || 'om ') avoids the problem. Looks like the parser isn't tokenizing strings before looking for keywords.
    Rodney

    Rodney,
    Looks like it just doesn't like the space at the beginning.
    That said, this worked for me:
    SELECT c001||chr(32)||'from ' d, seq_id r
    FROM apex_collections
    WHERE
    (collection_name = 'ABC'
    ORDER BY 1
    Chad

  • I've had Photoshop elements 8 on this machine for over two years and all of a sudden it is asking for a serial number. when I put it in it give me a serial number invalid message

    I've had Photoshop elements 8 on this machine for over two years and all of a sudden it is asking for a serial number. when I put it in it give me a serial number invalid message

    I am having the same experience. Did you find a solution??

  • I have Dreamweaver CS5.5 and all of a sudden I can't open it says XML parsing fatel error.  Invalid Document Structure  What do I do?  Thanks

    I have Dreamweaver CS5.5 and all of a sudden I can't open it says XML parsing fatel error.  Invalid Document Structure  What do I do?  Thanks

    You need to rename the Configuration folder to Configuration_BU.
    The folder can be found by following this http://www.dmxzone.com/go/16740/clearing-dreamweaver-s-cache/

Maybe you are looking for