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.
Similar Messages
-
Problems with customizing select lists and popup LOVs
Hi
I have 2 problems about select lists and popup LOVs.
The first one is about a select list in a tabular form.
It should be created with APEX_ITEM.SELECT_LIST_FROM_LOV or similar and take its values from a named LOV.
This worked fine but now it should also have the possibility to enter a free value.
I tried to accomplish that by creating a APEX_ITEM.POPUP_FROM_LOV, but there is a problem with the function that is called by the arrow icon right to the input field (for eg. genList_f11_5()).
If the row is added by addRow, then it works fine, but if the row is is not empty
then the function call is like genList_f11_$_row() and the input field gets no value, when a LOV option is selected.
The other problem is about a select list which should have the possibility to enter a custom value and
also there should be the possibility to select several values. I tried to implement this by a text area containing the selected values and a multiple select list, with an event handler in each option. The user could click options and they would be copied to the text area. The problem is that I couldn't make the event handler work in IE.
I would appreciate any ideas about either of these problems.
TiinaHi,
If you download application you can see source.
I have not write any instructions, sorry.
If you are on Apex 4 you can just load jQuery UI autocomplete library and take ideas from my app.
If you download my sample in zip there is uncompressed htmldbQuery library.
You can see that and take only function htmldbAutocomplete.
Then check jQuery UI document
http://jqueryui.com/demos/autocomplete/#method-search
There is method search that you can use open list just by click of input.
I hope this helps at start.
Regards,
Jari -
Select List (based on LOV) query problem
Hello experts! I have a small problem here, which I can't seem to overcome.
I have a page item (select list based on LOV), which is based on a query. The query returns all potential employees of a department that are responsible for a certain duty. So far so good!
The problem is that there are two departments, which should not only see there own employees but also the name of the employee that has carried out a certain task. However, due to my query, the name of that person is not displayed - only the pk is returned.
Do you have a recommendation how I display all employees of a specific department and have additional values translated as well?
My query is as follows: select str_bearbeiter, cnt_bearbeiter from vt_tbl_bearbeiter where cnt_bearbeiter in (SELECT
CNT_REGIERUNGSBEZIRK FROM TBL_REGIERUNGSBEZIRK) union select str_bearbeiter, cnt_bearbeiter from vt_tbl_bearbeiter where int_behoerde in (SELECT
CNT_REGIERUNGSBEZIRK FROM TBL_REGIERUNGSBEZIRK where STR_REGIERUNGSBEZIRK = lower (:app_user)) whereas :app_user holds the information of the department.
Any hint is appreciated!
Many thanks,
SebOkay, I just had the right idea and it's working well! Sorry for posting!
I return the name of the employee that has edited a dataset and simply add all others of the logged on department! Really easy! Should have thought of that before posting! ;-(
The correct code is select str_bearbeiter, cnt_bearbeiter from vt_tbl_bearbeiter a, vt_tbl_punktdaten b where a.cnt_bearbeiter = b.int_bearbeiter and
inv_pt_id_sub = :P4_PTIDS
union select str_bearbeiter, cnt_bearbeiter from vt_tbl_bearbeiter where int_behoerde in (SELECT
CNT_REGIERUNGSBEZIRK FROM TBL_REGIERUNGSBEZIRK where STR_REGIERUNGSBEZIRK = lower (:app_user))Bye,
Seb -
Select List and Popup LoV for one column
Hello,
is there a built-in functionality to show a select list and a popup lov for one column similar to "Condition Type" in the condition region when editing a page.Hello,
No, you have to code that yourself. For instance by adding HTML in the Post Element Text field (like <IMG src=... />).
Greetings,
Roel
http://roelhartman.blogspot.com/
http://www.bloggingaboutoracle.org/
http://www.logica.com/ -
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 -
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 -
Chart based on Select list with submit Lov problem
Hi,
I have one page with interactive report showing username with links, date and
database actions.
Another page contains one region having flash chart based on select list with submit Lov.
The lov is created by dynamic query.
Every time when i click the 1st page report link, the 2nd page lov is populating the value automatically. But the problem is chart displays NO DATA FOUND message though the LOV has many values.
I don't want to display any null values so set to NO for LOV
I tried to write Before header computation (PL/SQL Function Body) to set the lov value, but the query is displayed as such.
I don't want to assign any static default value also as the values are dynamic for every link.
The following is my Before header computation of Select list with submit (Item name is p11_schema). (PLSQL Function Body)
begin
if :p11_schema is null then
return 'select distinct owner schema1, owner schema2 from auditing
where access_date=' || :p11_access_date
|| ' and username=' || :p11_username
|| ' order by owner';
end if;
end;
This is my chart query.
select null link, obj_name label, sum(sel_count) "Select", sum(ins_count) "Insert", sum(upd_count) "Update", sum(del_count) "Delete" from auditing
where username=:p11_username
and access_date=:p11_access_date
and owner=NVL(:p11_schema, OWNER)
group by owner, obj_name
Example: If there more than one records in the lov, the graph should display the 1st record. When i select another record, the chart accordingly display the selected values. But inially it should not display "NO DATA FOUND" message.
I tried using all the combinations of computation type for the lov, SQL query ( I could not use if conditon then), PLSQL expression, PLSQL function body. But it does not work out.
Can anyone please help me out.
Thanks.Hi Scott,
Thanks for your reply.
I found out the solution for this problem as below.
But i did it in different way to tackle the dynamic query wich returns more than one record using rownum always the 1st record when it is empty instead of assigning constant (static) value like '1'. And i am returning LOV itself for both null or not null condition as below.
Declare
q varchar2(4000);
begin
if :p11_schema is null then
q:='select distinct owner schema from auditing';
q:=q || ' where username=:p11_username ';
q:=q || ' and access_date=:p11_access_date ';
q:=q || ' and rownum<2 order by owner';
Execute immediate q into :p11_schema USING :p11_username, :p11_access_date;
end if;
return :P11_SCHEMA;
end;
Thanks. -
Dynamically changing the select list in an LOV based on the login user
We have a field in a form which is a combobox.The form is to be linked to different profiles of users.Based on the logged in user we would like to restrict the select list in the LOV.ie user1 should see a LOV which is different from that seen by user2.Is this possible.If so how can this be done?Kindly reply.
Thanks & Regds,
JayanthiThanks for ur reply.But my problem is that i have a table having details of some products which includes spareparts also(Name,id,price etc).In my form i have the combobox field which should have a list of these products which the user can select.Now depending on the user's profile he should see only his related products(One profile of users should view only the products but not the spares while the other should view only spares.)The details of both the products and spares are in the same table.we have a criteria to differentiate between the products and the spares.The LOV should display at run time, either products or spares depending on his profile as he logs in. Hope u understood my problem.
Regds,
Jayanthi
Hello Jayanthi,
I had a similar situation in my last project.
While you can solve this by modifying your query, this will always come around as may be later some other criteria to restrict based on User/His Role/Something else. Hence I fixed it at design level itself. Though I can't give my situation I can tell you the solution applying my logic.
Altering your Product Table and adding one more database Column say Product_Category and updating the table with Product Category =1 for Products and 2 for Spares. You can extend this further for other types.
Create a new Table say User_Groups that will have
Group_id
Group_Name
User_Id columns and will contain all the User ids inserted groupwise.
Create one last Table Group_Product_Map
That will have
Group_id
Category_id
This will store each Group_Id followed by Category_id of Products to which these group members will have access to.
Now write a database function getCategory( p_User) which will query User_Groups table to get Group_Id
and further query Group_Product_Map Table based on group_id to get Category_Id.
This function will return category_id.
Huh!
So your LOV will have a query as select *(or whatever) from Product where category_id = getCategory(portal30.wwctx_api.get_user)
Hope this helps
Madhav -
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 nullHave 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
------------------------------------------------------------------- -
Populate a select list based on sql query
I need to populate a select list using an sql query based on the value value I get from the previous page sent using link . How can I achieve this behaviour ? I tried giving select app_item_id a,app_item_id b from app_item_definition where app_id = :P11_APP_TDL_ID order by 1 in LOV, but it doesn't work . Please advice .
Okay, I just had the right idea and it's working well! Sorry for posting!
I return the name of the employee that has edited a dataset and simply add all others of the logged on department! Really easy! Should have thought of that before posting! ;-(
The correct code is select str_bearbeiter, cnt_bearbeiter from vt_tbl_bearbeiter a, vt_tbl_punktdaten b where a.cnt_bearbeiter = b.int_bearbeiter and
inv_pt_id_sub = :P4_PTIDS
union select str_bearbeiter, cnt_bearbeiter from vt_tbl_bearbeiter where int_behoerde in (SELECT
CNT_REGIERUNGSBEZIRK FROM TBL_REGIERUNGSBEZIRK where STR_REGIERUNGSBEZIRK = lower (:app_user))Bye,
Seb -
Multiple selection list and passing that value to oracle reports
Hi
I need to create a multiple selection list and then based on use selection, I need to pass that value to oracle reports. Can any one help with steps on how I can do this. ThanksHi
Concatenate the multiple values into a string separated by comma and then pass that string to report as a parameter.
In report query, you have to use the lexical parameter using ' & '
regards
SD -
Report with select list and link to call another report
Hi,
I am trying to do 2 reports (REPORT1 and REPORT2).
The first is a summary report (REPORT1).
This report will display sales figures for the year. Now, I need to have a select list in the result set that will have 2 options, depending on which option is chosen, I want to call REPORT2 with the select list as a parameter. How can I do this ?
Let me try to explain what I did.
I created REPORT1 on Page 100
SELECT YEAR, sum(YTD_SALES), APEX_ITEM.SELECT_LIST(1,'DEPARTMENT','Department;DEPARTMENT,Division;DIVISION') Drilldown FROM SALES_ANALYSIS WHERE YEAR > 2000
GROUP BY YEAR ORDER BY YEAR
I created 2 hidden items namely P100_YEAR and P100_DRILLDOWN
I also made the column YEAR as a link and specified both P100_YEAR and P100_DRILLDOWN as parameters to be passed.
Next, I created REPORT2
SELECT YEAR, DECODE(:P100_DRILLDOWN, 'Department', department, 'Division', Division) dept_div, sum(YTD_SALES) ytd_sales
FROM SALES_ANALYSIS
WHERE YEAR = :P100_YEAR
When I run Report 1, it's fine, when I choose either Department or Division from the Select List and click on the link to call Report 2, report 2 is displayed, but the value being passed for P100_DRILLDOWN is not correct and as a result, I am unable to get correct results for Report 2
Am I missing something ? Are there any alternate ways to do what I'm doing ?
Thanks,
AshokHi Ashok,
The link definition will not know the value selected in the list as it is constructed only when the page is being rendered. You would need to create some javascript to handle this. I've done that here: [http://apex.oracle.com/pls/otn/f?p=267:182]
The link on the EMPNO column has been defined in the HTML Expression setting for the column instead of the Link section. The HTML Expression that I have used is:
<a href="#" onclick="javascript:doDrilldown('#EMPNO#',this);">#EMPNO#</a>And, in the page's HTML Header setting, I have added in:
<script type="text/javascript">
function doDrilldown(empno,group)
var g;
var p = group.parentNode;
while (p.tagName != "TR")
p = p.parentNode;
var x = p.getElementsByTagName("SELECT");
if (x.length > 0)
g = x[0].value;
var url = "f?p=&APP_ID.:183:&SESSION.::::P183_EMPNO,P183_GROUP:" + empno + "," + g;
document.location.href = url;
</script>When a link is clicked, the doDrilldown function is called passing in the EMPNO value and the "this" object (which identifies the object triggering the call). The function starts from that object and goes up in the HTML tag tree to the nearest TR tag (the row tag that the link is on) and then finds the first SELECT list item on the row and gets its value. It then constructs a URL using this and the EMPNO value and performs a redirect to the second page (page 183 in this example).
Andy -
Select list and date picker on one line - is this a bug?
I'm using: Application Express 3.2.0.00.27
Is the following a bug? If so, how do I get it reported so it will be fixed in a future release of APEX? If not, how do I do it so it ends up the way I want?
1. create blank page
2. create html region
3. create "select list" item (Begin On New Line - Yes, ...Field - Yes, ColSpan - 1, Row Span - 1)
4. create date picker item (Begin On New Line - No, ...Field - No, ColSpan - 1, Row Span - 1)
There will be other items displayed in more columns above what I just had you create above. I want the select list and the date picker to display next to each other on same line, so I placed date picker item on same line in same field as select list item.
HOWEVER... the date picker ends up displayed under the select list item (kind of), instead of next to it on the same line.
Here's what I get:
...................... [Select List Field] Date Picker Label
Select List Label
...................... [Date Picker Field]
Here's what I want:
Select List Label [Select List Field] Date Picker Label [Date Picker Field]
Thanks,
Steve
Edited by: sskelton on Aug 3, 2009 11:01 AM
Edited by: sskelton on Aug 3, 2009 11:02 AMHi Steve,
I'm not sure if it's the official way, but you could add a post here: Enhancement Request Thread : Post 3.1 - that's what I've been doing :D
Andy -
db11gxe , apex 4.0 , firefox 24 ,
hi all ,
i have a master detail page , with an item "test_id" as a select list ,
and a detail region has also a column "test_id" ,
what i want is :
when i change the value of the master "test_id" , the data is retrieved in the detail region where "test_id" = "master_test_id" ;
how to do so ?
thanksNewbi_egy
Do you mean that when you change the test in the master you want to refresh the detail?
Can you put up an example of your tables and foreign keys etc. on apex.oracle.com.
To me this sounds a wrong model design.
The detail should only depend on the primary key of the master. And the primary key shouldn't be updatable.
Nicolette -
Question on Dynamic Select Lists and Checkboxes
Hello,
I am new to APEX, and this is my first posting, I have a question about how to implement dynamic checkboxes from a select list.
Basically I would have a select list, and based on what item is selected a set of checkboxes would appear.
I was originally using the Select and Submit property on the select box, which works fine, all of the checkboxes appear appropriately. But the thing is, APEX refreshes the page each time, and since this select box is lower in the page, the user would have to scroll all the way down to where they were before.
The main requirement is so that the user won't have to scroll down the that position where the select box is each time they select a new option.
So a work around attempt is to create a javascript that will automatically scroll down to that position on page load ...
i.e.
function pageScroll() {
window.scrollBy(0,50);
But that didn't work, because for some reason the javascript wasn't appearing.
Is there a way to either:
1. Have a dynamic checkbox appear using ajax? -or-
2. Have the javascript scrolling effect
Sorry if this is a confusing question, I was wondering if anyone else came across this issue.
Thanks in advance!!Since this Select List plays such an important role on the page, why not create a side-region and put that select list there so you don't have to overwhelm the user and his 'persistence of vision ' with a page that scrolls all by itself to the 1000th line to, then , change the options ?
just an idea.
Maybe you are looking for
-
MSI Neo2-P network cable unplugged
Hello I am new here and do not come even close to posessing the levels of knowledge I havbe read in some posts. That said I have an issue that I found some threads slightly relevant to but not entierly.\ I have a MSI Neo2-P with the realtek network
-
Dual graphics - I cant run radeon, only intel.
I have laptop Lenovo G510. It has integrated Intel graphics card and Radeon HD 8570M. I wanted use only radeon (with xf86-video-radeon), but only drivers for intel (xf86-video-intel) working. [x@arch64 ~]$ lspci | grep -e VGA -e 3D 00:02.0 VGA compat
-
Hi all When i'm trying to select layout in abobe form, its shows following error occured "Error occurred in communication with layout editor" Anyone help me how to solve this issue?
-
How to apply condtion formula inside Report Writer and Report Painter
Hi anybody, I am doing report painter. but i don't know how to include condition formula inside report painter or report writer. ex if condition .. Anybody please explain to me the steps of report writer how do this. I will appreciate goods answers t
-
Can I boot imac from macbook install disk 1?
I'm trying to install BootCamp on my intel iMac but it keeps failing at the disk partition, now having repaired permissions and verified the disk the help file tells me to boot my iMac from a startup disk and then load a disk utility. I can't find my