Subquery in SELECT list vs join
If I'm not mistaken, both queries below are functionally the same. Both return all rows from table1 and only show a value for table2.F7 if the first 4 characters of F7 equal F2.
My thoughts are this... It's nice that a subquery can be used in a select list, but it looks like, with all the sql I've written which uses that approach, I could have just as well used the join approach. Is this always true? Can someone show me as example where using a subquery in the select list is hands-down the better approach?
SELECT table1.F2,
(SELECT table2.F7 FROM table2 WHERE substr(table2.F7,1,4) = table1.F2)
FROM table1
SELECT table1.F2, table2.F7
FROM table1, table2
WHERE table1.F2 = substr(table2.F7,1,4)(+)
Let me add that, in my top example, multiple rows will never be returned by the subquery. If that were the case, then the join approach would be the only option.
Message was edited by:
Nick2012
Probably there is no general answer and you'll always have to check separately.
In the following example the scalar subquery turns out to be slightly more efficient than an outer join (15 gets versus 13 gets and compare the elapsed time):
SQL> SET autotrace traceonly explain statistics
SQL> SET timing on
SQL>
SQL> SELECT ename, (SELECT dname
2 FROM dept d
3 WHERE d.deptno = e.deptno) dname
4 FROM emp e
5 /
14 rows selected.
Elapsed: 00:00:00.72
Execution Plan
Plan hash value: 2981343222
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 15 | 135 | 3 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| DEPT | 1 | 11 | 1 (0)| 00:00:01 |
|* 2 | INDEX UNIQUE SCAN | PK_DEPT | 1 | | 0 (0)| 00:00:01 |
| 3 | TABLE ACCESS FULL | EMP | 15 | 135 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("D"."DEPTNO"=:B1)
Statistics
0 recursive calls
0 db block gets
13 consistent gets
0 physical reads
0 redo size
742 bytes sent via SQL*Net to client
381 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
14 rows processed
SQL> SELECT ename, dname
2 FROM emp e, dept d
3 WHERE d.deptno(+) = e.deptno
4 /
14 rows selected.
Elapsed: 00:00:00.74
Execution Plan
Plan hash value: 3387915970
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 15 | 300 | 7 (15)| 00:00:01 |
|* 1 | HASH JOIN OUTER | | 15 | 300 | 7 (15)| 00:00:01 |
| 2 | TABLE ACCESS FULL| EMP | 15 | 135 | 3 (0)| 00:00:01 |
| 3 | TABLE ACCESS FULL| DEPT | 5 | 55 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - access("D"."DEPTNO"(+)="E"."DEPTNO")
Statistics
0 recursive calls
0 db block gets
15 consistent gets
0 physical reads
0 redo size
666 bytes sent via SQL*Net to client
381 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
14 rows processed
Similar Messages
-
hi all
i have a table that name is:
TiketsHeader
but i used this code
SELECT TicketsHeaderId, Active, TH.PersonRef,P.Fname + ' ' + P.Lname AS NF, Serial, TicketsCnt, StartSerial, EndSerial, KindDate, StratDate, EndDate,
MonthsRef1,(SELECT * FROM dbo.Months M WHERE M.MonthsId= MonthsRef1 ) AS MonthsName1 , MonthsRef2, MonthsRef3, WeekDaysRef,
PoolTimesRef, TH.Descreption
FROM dbo.TiketsHeader TH
INNER JOIN Person P ON P.PersonId= TH.PersonRef
i see this error:
Msg 116, Level 16, State 1, Line 2
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
how to solve it
please help me
Name of Allah, Most Gracious, Most Merciful and He created the humanSELECT TicketsHeaderId, Active, TH.PersonRef,P.Fname + ' ' + P.Lname AS NF, Serial, TicketsCnt, StartSerial, EndSerial, KindDate, StratDate, EndDate,
MonthsRef1,(SELECT * FROM dbo.Months M WHERE M.MonthsId= MonthsRef1 ) AS MonthsName1 , MonthsRef2, MonthsRef3, WeekDaysRef,
PoolTimesRef, TH.Descreption
FROM dbo.TiketsHeader TH
INNER JOIN Person P ON P.PersonId= TH.PersonRef
A Sub query like this can only return one column, not serveral like here with the star *. Replace the star by one column Name that you want to query.
Olaf Helper
[ Blog] [ Xing] [ MVP] -
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 PMI 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. -
Select List or Radio Buttons query with multiple tables join
Hello,
I'm having a problem creating a select list or a radio group item.
I need to display the emp_first_name in the select list but have the return value of the order_id in the select list or radio buttons item.
The tables are as follow:
emp_table
emp_id
emp_first_name
emp_last_name
etc...
orders_table
order_id
order_name
emp_id
etc...
I need to display the emp_name from emp_table in the select list but return the order_id from the orders_table as the return value.
How can I do this?
Any help would be greatly appreciated.
Thanks.
Regards,
NJHi NJ,
Try:
select e.emp_first_name d,
o.order_id r
from orders_table o
inner join emp_table e on o.emp_id = e.emp_id
order by 1You may have an issue with an emp_id being used for more than one order and, therefore, the employee's name appearing more than once in the list?
Andy -
ORA-30563, Outer Join not allowed in select list
I can not find any information about this error message that I am getting.
I have just upgraded my Oracle database from Version 7.3 to Version 8.1.7, a stored procedure that was written in v7.3 has outer joins in the select statement.
when trying to run this proc in version 8 I get this meesage.(ORA-30563, Outer Join not allowed in select list)
code ex:
Select alt.id
decode(alt.advise, NULL, NULL, AA.act_yr(+))||'-'||AA.act_per(+)||'-'||AA.Acc_per_no(+)) as advise_no
from alt, AA;
Is there any information about this message anywhere? or does anybody know if this is a known issue with oracle ver 8.1.7?
Thanks
CJIt appears to have been a bug in 7.x
From a metalink note on bugs fixed in 8i (doc 132632.1)
974742 Oracle does not report an error if (+) is specified in select-list. The OUTER JOIN operator (+) is only valid in WHERE clause predicates. As this is not flagged as an error the query can give unexpected results. The correct action to avoid this problem is to fix the query.
Ken -
Outer Join problems - "ORA-30563 outer join operator (+) not allowed in select-list"
Products: Discoverer 4.1.33.0.2
(Admin and User/Plus)
8i EE 8.1.7 (Discoverer server)
8i EE 8.1.5 ('source data' server)
Background assumptions: (1) If a column from an "outer-joined" table is compared to a constant, the outer join operator must be applied to that column in order for the outer join to work. (2) A 'Condition' specified in Discoverer User/Plus manifests as a comparison to a constant.
I created a join in Admin between two folders, selected 'outer join on detail' option. In User/Plus, created worksheet containing columns from the joined folders. When no Conditions are NOT specified, results seem ok. However, when Condition IS added, worksheet encounters "ORA-30563 outer join operator (+) not allowed in select-list" and returns blank sheet.
To workaround, created Custom folder with outer join in place. Didn't work either with Conditions specified. No error, but I think that because Discoverer did not 'outer join' the Condition column, the outer join was ignored.
Any insights, ideas, or workarounds are much appreciated.
-JimIf you build a query that uses an outer join then any items from the potentially deficient side of the join will have (+) appended to them everywhere in the sql. Up until 8.1.7 this was OK in the select list as it was just treated as noise and ignored - However this now fails with ORA-30563:
outer join operator (+) not allowed in select-list...
In 4.1.33.1.6 you get the error 'ORA-30563 outer join operator(+) not allowed in select list'.
In 4.1.36.1.10 the query runs OK.. Your work around I would guess would be to create a custom folder as you suggested. -
Hello,
Can anyone help me?
select year(po.rdata) as 'Ano',
sum(etotal) as 'Valorp' ,
(select year(fo.data),Sum(etotal)
FROM fo (nolock)
where not exists ( select 1 from pl (nolock) where pl.adoc = fo.adoc and pl.cm = fo.doccode )
group by year(fo.data))as 'Valorap'
from po
group by year(po.rdata)
order by year(po.rdata)
Error
Msg 116, Level 16, State 1, Line 6
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
ConsultoraHi Prashanth,
select year(po.rdata) as 'Ano',
sum(etotal) as 'Valorp' ,
(select Sum(etotal)
FROM fo (nolock)
where not exists ( select 1 from pl (nolock) where pl.adoc = fo.adoc and pl.cm = fo.doccode )
group by year(fo.data))as 'Valorap'
from po(nolock)
group by year(po.rdata)
order by year(po.rdata)
Gives me the error:
Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
Thanks
Consultora -
Dynamic select list with display,return val & join condition issue.
hello,
I am having a dynamic select list with display, return value
say for example my select statement is
select distinct dname d, deptno r
from dept dt
right join emp e on (e.deptno=dt.deptno)
where (condition)
when i tried this query for my select list, it is not working. It saying that
" 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. "
I am not able to understand the problem. Can anyone help me out with this issue?
thanks.Shouldn't your join have dept as the driving table?
select distinct dname d, deptno r
from dept dt
right join emp e on (dt.deptno = e.deptno)
where (condition)
Or using older Oracle standard join
select distinct dname d, deptno r
from dept dt, emp e
where (dt.deptno (+) = e.deptno) AND (OTHER WHERE condition)
OR
(Since a right join is just getting the values from the driving table that are NOT in the associated table)
select distinct dname d, deptno r
from dept dt
WHERE dt deptno NOT IN (SELECT deptno FROM emp) AND (OTHER where condition)
Thank you,
Tony Miller
Webster, TX -
LOV an SQL : how to configure a select list to get all records
Hello,
I am using Oracle 10g with APEX 2.0.
Here is my question:
I have a report and I am using 3 text fields and a select list to search through a join of two tables. The select list is composed of a "list of values" and the parameter, which is used in the SQL-sentence, has a numeric value.
Result table after the join operation looks like this:
Field1 Field2 Field3 Field4 (By assuming the field3 is the one which used in the select list.)
21a this 1000 bn
21a that 1001 vb
33c thus 1012 ct
What I want to do is to set another parameter-value pair in the select list to let user choose the "ALL" of the mentioned items in the select list so that the search will return all the records without having taken this select list-field into consideration.
Is it possible to do it with LOV and SQL? Do I need any other functions? or configurations?
Thanks in advance,
SedefHi user630478!
I always use a select list with submit and the option to get a NULL-Value for such things. To solve your problem do the following things:
1.) Create two named LOVs. One as you already did and another one for all values.
2.) Your select list with submit should be configured to show a NULL-Value e. g. it shows ALL with the value 0.
3.) Create two conditional branches that work together with your select list. One that show the normal results if a user has clicked on a normal value and the second should act only if a user has clicked on ALL.
4.) Write a process that switches the LOVs in your select list from one to the other. This process should only be fired if the second conditional branch has been actived.
Maybe if I understood right that's what you want to know.
yours sincerely -
Select list from query in report
Hello everybody,
I want to include a select list from a query in a report's colomn, but the select list should only be displayed conditionally. I wanted to do this with the help of "case when" in the corresponding SQL statement.
The select list itsself works, but when I combine it with "case when" I always get the error message:
ORA-01427: single-row subquery returns more than one row
The select statement is as following:
select
htmldb_item.checkbox(1,rownum) " ",
x.idee,
x.stunden_ilp,
x.stunden_ild,
x.stunden_ilm,
x.stunden_ief,
x.stunden_ir,
x.pe_id,
x.l_art_id,
x.version_id
from (
select
(select case
when (select name from cn_pl_projektidee s01
where s01.idee_id = '2') IS NULL then
(select distinct htmldb_item.select_list_from_query(5,name,'select distinct name from cn_pl_projektidee') name from cn_pl_projektidee s01
where s01.idee_id = t1.idee_id)
else
(select distinct htmldb_item.text(5,name) name from cn_pl_projektidee s01
where s01.idee_id = t1.idee_id)
END from cn_pl_std_peplanung t1) Idee,
from cn_pl_std_peplanung t1, cn_pl_projektelemente z1, cn_pl_version u1, cn_pl_projektidee s1
where t1.version_id = '&P6_VERSION_WAHL.'
and t1.pe_id ='&P6_HELP_PRODET.'
and t1.l_art_id ='&P6_L_ART_ID.'
group by t1.pe_id, t1.version_id, t1.idee_id, t1.l_art_id) x
order by x.ideeDoes anybody know what could be the problem or what other solutions I could try??
Greetings!
PatrickFound 2 ways to solve it:
*1. dynamic action (JQuery)*
$("#f20_1234 option[value=13]").attr('selected', 'selected');
*2. process*
BEGIN
HTP.p('<script type="text/javascript">');
--HTP.p('problem()');
HTP.p('html_SetSelectValue(''f20_903'',188)');
HTP.p('html_SetSelectValue(''f20_903'',189)');
HTP.p('</script>');
END; -
ORA-01785: ORDER BY item must be the number of a SELECT-list expression
I have a dynamic SQL on a page. The SQL is dynamic because there are 3 LOV fields from which the user may make selections, and those field values are used in the WHERE clause. Also, the 2nd LOV field is populated with AJAX based on the 1st LOV's selection. And, the SQL joins to another table. The report has 7 sortable columns. The main table the SQL runs over has about 1,000 rows in it.
The 2nd table has about 500 rows. (Sorry, I'm not sure what information you might need to help me, so I listed several details.)
The application, and page, have been working flawlessly for several weeks. Then, yesterday the page was being used and the user received the "ORA-01785: ORDER BY item must be the number of a SELECT-list expression" error. The error just appeared out of the blue, so to speak. After weeks of of usage this is the first time this error has appeared. The application had not been changed, but they had been entering data into the main table and the table joined to in the SQL. The application is in production, so I can't put the application into DEBUG, etc. to see what SQL is being built.
Anyway, I was trying to debug the page today and was doing selections and seeing what would display, then as suddenly as the page quit working it started working correctly. No code changes made, no server changes made (to my knowledge), and no data changes made.
I'm new to both Oracle and Apex, and am not a SQL, Oracle or Apex expert. So, I am very perplexed and don't have any idea of what could be happening.
I don't know if it's an issue with the SQL, AJAX not loading the select fields properly, a corrupted table, a server load issue, or something else all together.
Any suggestions?
Also, I'm not familiar with Oracle error messages. Can they be red herrings sometimes? Because, I don't programmaticly code the ORDER BY of the SQL. Apex appends that part. So, how could that aspect quit working. And, then suddenly start working.
Sorry, but I'm extremely confused. :-) Any suggestions or help will be greatly appreciated.
Thanks, TonyHi Dan,
Thanks for the feedback. I'm not going to be dogmatic about possible cause, but it has myself and another Oracle developer (who writes SQL and PL/SQL in his sleep) stumped. He doesn't think it's the SQL. Your suggestion was one of the first things we thought of considering the error message we got, but from Scott's reply that it could be a red herring, and after additional testing we've ruled the SQL out for now.
I understand what you're saying, but the SQL selects all the columns (about 40 columns are selected) that are sortable columns on the report. I've sorted by all the columns by clicking on them and that aspect works without error.
The SQL is created dynamically and is quite large. I've included below just for information purposes.
Thanks, Tony
= = = = = = =
DECLARE
q VARCHAR2 (4000);
BEGIN
q := 'select ';
q := q || 'hd."ID", hd."MODEL", hd."YEAR", hd."HIN", hd."BOAT_STATUS", hd."SPECIAL_ACTIVITY", hd."PARTIAL_KIT_VALUE",
hd.OPTION_NUMBER || '' - '' || e.DESCRIPTION OPTION_NUMBER,
hd."OPTIONS_HOURS", hd."OPTIONS_MATERIAL", hd."STATION", hd."ACTIVITY_COMMENT", hd."BI_EQUIV_MATERIAL",
hd."BI_EQUIV_LABOR", hd."EI_EQUIV_MATERIAL", hd."EI_EQUIV_LABOR", hd."BASE_BOAT", hd."SA_ENGINES",
hd."SA_OPTIONS", hd."DY_STANDARD_MATERIAL", hd."DY_STANDARD_LABOR", hd."DY_STANDARD_OVERHEAD",
hd."DY_STANDARD_ENGINE", hd."DY_ENGINE_ENGINEUP", hd."DY_ENGINE_MATERIAL", hd."DY_ENGINE_LABOR",
hd."DY_ENGINE_OVERHEAD", hd."DY_OPTIONS_MATERIAL", hd."DY_OPTIONS_LABOR", hd."DY_OPTIONS_OVERHEAD", hd."EI_STANDARD_UNITS", hd."EI_STANDARD_MATERIAL", hd."EI_STANDARD_LABOR", hd."EI_STANDARD_OVERHEAD", hd."EI_STANDARD_ENGINE", hd."EI_ENGINE_ENGINEUP", hd."EI_ENGINE_MATERIAL", hd."EI_ENGINE_LABOR", hd."EI_ENGINE_OVERHEAD", hd."EI_OPTIONS_MATERIAL", hd."EI_OPTIONS_LABOR", hd."EI_OPTIONS_OVERHEAD",
htmldb_item.hidden(50,hd.ID) idalias ';
q := q || 'from "PLP_HIN_DETAIL" hd , "PLP_ENGINES" e ';
IF
:P10_SEARCH_MODEL IS NOT NULL
AND :P10_SEARCH_MODEL <> '%null%'
AND :P10_SEARCH_YEAR IS NOT NULL
AND :P10_SEARCH_YEAR <> '%null%'
AND :P10_SEARCH_STATUS IS NOT NULL
AND :P10_SEARCH_STATUS <> '%null%'
THEN
q := q || 'WHERE
(instr(upper(hd.MODEL),upper(nvl(:P10_SEARCH_MODEL,hd.MODEL))) > 0
AND instr(upper(hd.YEAR),upper(nvl(:P10_SEARCH_YEAR,hd.YEAR))) > 0
AND instr(upper(hd.BOAT_STATUS),upper(nvl(:P10_SEARCH_STATUS,hd.BOAT_STATUS))) > 0)
AND e.OPTION_NUMBER (+) = hd.OPTION_NUMBER and e.YEAR (+) = hd.YEAR AND e.MODEL (+) = hd.MODEL AND e.PLP_ID (+) = hd.PLP_ID';
ELSE
IF
:P10_SEARCH_MODEL IS NOT NULL
OR :P10_SEARCH_YEAR IS NOT NULL
OR :P10_SEARCH_STATUS IS NOT NULL
THEN
q := q || 'WHERE
(instr(upper(hd.MODEL),upper(nvl(:P10_SEARCH_MODEL,hd.MODEL))) > 0
AND instr(upper(hd.YEAR),upper(nvl(:P10_SEARCH_YEAR,hd.YEAR))) > 0
or instr(upper(hd.BOAT_STATUS),upper(nvl(:P10_SEARCH_STATUS,hd.BOAT_STATUS))) > 0)
AND e.OPTION_NUMBER (+) = hd.OPTION_NUMBER and e.YEAR (+) = hd.YEAR AND e.MODEL (+) = hd.MODEL AND e.PLP_ID (+) = hd.PLP_ID';
else
q := q || 'WHERE e.option_number = hd.option_number and e.year = hd.year and e.model = hd.model and e.plp_id = hd.plp_id';
END IF;
END IF;
q := q || ' AND :P0_PLP_ID = hd.PLP_ID';
return q;
END; -
1 Conditional report based on 3 select lists/ 3 different select statements
I have made 1 report based on the three select lists. The report is displayed in the center of the page. The user needs to fill them in order, the select lists are:
Selectlist:
1. P1_LOVPG - Null is allowed, but is only appearing at top with a label of Productgroup
2. P1_LOVSG - Null is allowed, but is only appearing at top with a label of Subgroup
3. P1_LOVMA - Null is allowed, but is only appearing at top with a label of Manufacturer
LOVPG contains a distinct collect of the ProductGroups
QUERY LOV = select distinct pg from X
LOVSG contains a distinct collect of the SubGroups inside the selected PG.list
QUERY LOV = select distinct sg from X where pg = :P1_LOVPG
LOVMA contains a distinct collect of the Manufacturers inside the selected SG.lst
QUERY LOV = select distinct ma from X where sg = :P_LOVSG
Based on the the selected items the user would see the following:
Table X
PG SG MA ART
A-----X----M---1
A-----X----N---2
A-----Y----M---3
A-----X----M---4
B-----X----M---5
B-----Y----N---6
B-----Z----O---7
Seletion 1 PG = A -> selects PG A in select list result, User sees:
Report A
PG SG MA ART
A-----X----M---1
A-----X----N---2
A-----Y----M---3
A-----X----M---4
Query would be: select * from X where PG = :P1_LOVPG
Selection 2, user still sees the above, can only select from the SG select list NULL, X, Y. User needs to choose between X or Y value. He picks X, he sees:
Report B
PG SG MA ART
A-----X----M---1
A-----X----N---2
A-----X----M---4
Query would be: select * from X where PG = :P1_LOVPG and SG = :P_LOVSG
Selection 3, user still sees selection 2 on his screen, can only select from the MA list bewteen NULL, M or N, user needs to choose between M or N. He picks M, he sees:
Report C
PG SG MA ART
A-----X----M---1
A-----X----M---4
Query would be: select * from X where PG = :P1_LOVPG and SG = :P_LOVSG
As you can see the query changes as the user goes deeper into the structure. It is a simple if then else system where the quey changes. How do I set this up in htmldb?
(I've read something about Oracle's SQL and it's decode function, but can they be used with changing select statements?)are you sure your data meets the JOIN conditions?
You can make a quick check.. only example...
select single * from KONP into ls_konp
where knumh = P_knumh.
if sy-subrc eq 0.
select * from from A905 into table lt_a905 where
kappl in so_kappl
and kschl in so_kschl
and VKORG in so_vkorg
and vtweg in so_vtweg
and kondm in so_kondm
and wkreg in so_wkreg
and knumh = ls_konp-knumh.
if sy-subrc eq 0.
select * from A919 into table lt_a919
for all entries in lt_a905
where kappl = lt_a905-kappl
and kschl = lt_905-kschl
and knumh = lt_905-knumh.
endif.
endif. -
Using ORDER BY for column that's not in SELECT statement of select list?
Hi all.
I have a select list on an APEX page at apex.oracle.com, and I would like to order this by the value of column UnitOrder.
The SQL is as follows:
SELECT DISTINCT foodunit.name AS display_value, foodunit.foodunitid AS return_value
FROM foodunit, food
WHERE foodunit.foodid = :P18_FOODID
ORDER BY foodunit.unitorder ASC;Off course, this code won't work. And since it's a select list, I can't just add foodunit.unitorder to the SELECT statement. Also, I can't get rid of the DISTINCT, because then for some reason it tends to display an infinite amount of the same row...
The point of ordering it by UnitOrder is that all units who begin with gram, ml, mg, kg,... etc, will be shown on top of the select list. All other food units will be shown on the second place and so on.
The column UnitOrder holds either 1 or 2 as a value. 1 is the value for all rows that should be displayed at the top of the select list, 2 is the value for all the rest.
So, what I want is that all rows in which the UnitOrder is 1, get displayed on top of the select list. Usually only 2 list items get shown in the select list at a time, depening on which food item a user has selected. The select list then refines to certain rows that match the foodid etc etc..
If anyone has an idea, I'd be very happy to hear about it.Thanks! I didn't think about using a join. Code works now, and is as follows:
SELECT foodunit.name AS display_value, foodunit.foodunitid AS return_value
FROM foodunit
INNER JOIN food
ON food.foodid = foodunit.foodid
WHERE foodunit.foodid = :P18_FOODID
ORDER BY foodunit.unitorder ASC; -
Say I have a dataset like (status_code,status_desc,color). A select list uses the code & desc but I would like to use the color of each status to be used as the background color for that entry. Patrick shows how to do this for a simple case right using the Element properties but how would this be done in my example?
I was thinking of using apex_util.json_from_sql to get the status_code & color in a Before Footer process and use Javascript to set the colors. But I couldn't figure out how to use the JSON as an associative array i.e. row[status_code] = color.
Comments? ThanksHello Vikas,
>> But when the page is submitted, Complete will be stored in session state and this is not one of the values returned by the LOV query …
Yes, sorry about that, I forgot I’m also using a Post Calculation Computation on the item, which calls a function that builds a matching value to the LOV. Something like:
select_list_color(:P1_SELECT);The body of this function is, of course, depends on the way/source to derive the status color. In my case, it looks like:
function "SELECT_LIST_COLOR" (
p_color_name in VARCHAR2
) return VARCHAR2
is
l_color_code varchar2(20) := '';
BEGIN
if p_color_name is not null then
select code into l_color_code
from mis_color_code
where color = p_color_name;
end if;
return p_color_name || ':' || l_color_code;
END;
>> … so the LOV item needs to have "Show Extra Values" turned on
That’s not good enough as the Extra Value doesn’t include color code so the select list entry will not be colored (which defeat the original purpose).
>> Or maybe you have an after-submit computation to join the Complete and Green again so page rendering continues to work fine.
That’s also not good enough. First, I don’t want to impair the integrity/consistency of the session state. Secondly, if, for example, you are using ARF to populate the select list item, you’ll have the same problem, so after-submit computation is not enough.
The best solution I could think of is to use the Post Calculation Computation. So far it’s working very good.
Your solution, using AJAX, is also valid (and more importantly, it seems to work for you) however, in this specific scenario, where all the information is actually available to you pre-rendering the page, another trip to the database seems too costly (especially in my case, where some of the communication is over the Internet, using very crowded lines).
Regards,
Arie.
♦ Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.
♦ Forthcoming book about APEX: Oracle Application Express 3.2 – The Essentials and More -
APEX 4.0.2 Multi-selection on a cascade LOV select list only pass 1 value
Hello everyone,
I am struggling to make a cascading LOV select list has multi-selection.
On one report page.
I have 2 select list
The first one lists the court name (P4_COURT_NAME), the second one (P4_DEFENDANT) list all defendants who currently engaged in the court.
The problem is when I allow the defendant select list become multi-select, when it submit it only pass the first selected value.
So I create just a simple select list based one list of value, and make it allow multi-selection. When it submit, the normal select list can pass selected values properly, while the cascade LOV select list pass only the first selected value.
Please help if any of you have an idea why.
We use APEX 4.0.2.00.07, Oracle data version iis 11g
The some configuration settings I set for the P4_DEFENDANT IS
Value required: Yes
Page Action When value changed: None
Allow Multi Selection: Yes
Named LOV: --Select Named LOV-
Display Extra value : Yes
Display Null Value: Yes
Null Display Value: --Select—
Null return value:
Cascading LOV Parents Items: P4_COURT_NAME
Page Items to Submit: P4_DEFENDANT
Optimize refresh: YES
List of value definition
SELECT def.first_name || ' ' || def.surname || ' (PRN: ' || def.prn || ' )' as d, def.def_id as r
FROM defendant def INNER JOIN court_engagement ce
ON def.def_id = ce.defendant_id
WHERE (ce.date_joined_aodt_court IS NOT NULL
AND (ce.date_terminated IS NULL OR to_date(ce.date_terminated,'dd/mm/yyyy') > to_date(sysdate,'dd/mm/yyyy'))
AND UPPER(ce.court_name) LIKE UPPER(:P4_COURT_NAME)
AND ce.active = 1)Source Used: Only when current value in session state is null
Source Type: Static Assignment
Maintain session state: Per session
The rest is default.
Thanks in advance.
AnnHi Chintan,
The "Source used" for those items are "Always, replacing any value in the session state". To set them to "Only when current value in session state null" sounds a good solution to me.
However, a strange thing just happened - now I will not lose the values of the items after the page reloading, although I have changed nothing in the page in my application since I asked the question. I don't understand why all of a sudden the reloading doesn't make me lose changed values any more. Let me dig it tomorrow to see what I'll find.
Thanks so much for your help.
Christine
Maybe you are looking for
-
Annoying creation of TRC file every time I run script
I'm using SAPNWRFC and everytime I run a script an XML tracefile is created. In my sap.yml file I have: ashost: <my hostname> sysnr: "00" client: "000" user: <username> passwd: <pwd> lang: EN trace: 0 debug: 0 Tracefile starts
-
i have a ipod touch 2nd generation 8gb 4.2.1 im new to itunes i made a itunes account but it says i need a payment method is there anyway i can use my paypal if not is there a way to not have to use a payment method for itunes store please help ty
-
Payment in different currency then Invoice currency
Hello, I would like to know whether the scnario below will work or not. Scnario: Invoice posted in USD and we want to make the payment in SGD, payment method used for invoicewill allow to make payment in SGD. Suggestion or any documenation welcome..
-
CS6 Update Failure - Error U43M1D204 (new content added to question)
Web and Design Premium install. I get this error when running an Adobe Application Manager update in any of the products. Per one tech note found, I deleted the local profile folder for the logged on admin user where the updates are downloaded and
-
User Want multipale selection in Drill filter in WEB-I 3.1
Hi Team, we have WEB-I report created with Drill filter on it , we have set up drill fillter uisng anyalsis context by enabling report for drill. Now by default we can choose only one value from that fillter , we have requirment to enable it for mult