Tabular form from query with outer join destroys the universe!
Well, maybe just my app...
At any rate, what I have is a query that pulls RISKS for a project and does a reasonable outer join which joins the latest value from a RISK_HISTORY table. Values for RISK are updated and the value for RISK_HISTORY is changed and a new entry added to the RISK_HISTORY table.
At least that's how it's supposed to be.
I was able to do this with a report-with-a-form region by adding an extra update process to do a new insert into RISK_HISTORY but it seems that the tabular form is a bit more work.
Here's the query I'm using:
select * from(
select
r.RISK_SEQ RISK_SEQ_DISPLAY,
r.RISK_PRIORITY,
r.RISK_INFO,
r.RISK_MITIGATION,
r.ONGOING_FLAG,
r.RISK_DATE,
r.WEEK_GROUP_SEQ,
r.CREATED_ON,
r.CREATED_BY,
r.LAST_MODIFIED_ON,
r.LAST_MODIFIED_BY,
rh.STATUS,
row_number() over (partition by rh.risk_seq order by rh.last_modified_on desc) rn
from RISK r, WEEK_GROUP w, RISK_HISTORY rh
where w.PROJECT_SEQ=43
and r.week_group_seq= w.week_group_seq
and w.week_index=0
and rh.RISK_SEQ = r.RISK_SEQ
) where rn = 1
Clicking "Add Row" gets me this:
Error in mru internal routine: ORA-20001: no data found in tabular form
Running debug doesn't seem to expose much for me either. Is there a better tact for me to take here?
Thanks,
Jon
Hi Prazy,
using nvl also didn't solve my problem.Actually my problem is I am having a table a in which I have a column called satus, status has the values like A or I .I have one lookup called MTH_BUYSINESS_FUNCTION in which for lookup_code A I have menaing as Active and for lookup_code I meaning is Inactive.Now in table a for sttaus I have two values one A and one null Now I want to write sql which displayes the meaning for column staus.Result should be Active and null .If I am uisng 1 query which I gave u I am not able to get the 2nd row in my output.If I use 2nd query then I get duplicate rows.
Thanks ,
Amrit
Similar Messages
-
Rewrite the query with out joins and group by
Hi,
This was an interview question.
Table Names: bookshelf_checkout
bookshelf
And the join condition between these two tables is title
We need to rewrite below query without using join condition and group by clause ?
SELECT b.title,max(bc.returned_date - bc.checkout_date) "Most Days Out"
FROM bookshelf_checkout bc,bookshelf b
WHERE bc.title(+)=b.title
GROUP BY b.title;When I was in college, I read that most of the SELECT statements can be replaced by basic SQL operations (SET OPERATORS). Now I am trying to rewrite the query with SET operators but not able to get the exact result.
Kindly help me on this.
Thanks,
SuriSomething like this?
1 WITH books AS (
2 SELECT 'title 1' title FROM dual UNION ALL
3 SELECT 'title 2' FROM dual UNION ALL
4 SELECT 'title 3' FROM dual ),
5 bookshelf AS (
6 SELECT 'title 1' title, DATE '2012-05-01' checkout_date, DATE '2012-05-15' returned_date FROM dual UNION ALL
7 SELECT 'title 1' title, DATE '2012-05-16' checkout_date, DATE '2012-05-20' returned_date FROM dual UNION ALL
8 SELECT 'title 2' title, DATE '2012-04-01' checkout_date, DATE '2012-05-15' returned_date FROM dual )
9 SELECT bs.title, MAX(bs.returned_date - bs.checkout_date) OVER (PARTITION BY title) FROM bookshelf bs
10 UNION
11 (SELECT b.title, NULL FROM books b
12 MINUS
13* SELECT bs.title, NULL FROM bookshelf bs)
SQL> /
TITLE MAX(BS.RETURNED_DATE-BS.CHECKOUT_DATE)OVER(PARTITIONBYTITLE)
title 1 14
title 2 44
title 3Lukasz -
Query with outer join not dispalying the correct results
Hi All,
I am having a table which has a column called status it can either be null or has the code which comes from the lookup b.When I use this query
select b.menaing from a
where a.status=b'lookup_code(+)
AND b.lookup_type='MTH_BUSINESS_FUNCTION'
AND b.LANGUAGE = USERENV('LANG')
then I don't get the rows from table a, where status is null
and if I use the condition:
select b.menaing from a
where ((a.status IS NULL) OR
(a.status=b.lookup_code
AND b.lookup_type='MTH_BUSINESS_FUNCTION'
AND b.LANGUAGE = USERENV('LANG') ))
then I get many extra rows.Can soemone please tell me hwo to achieve this(My query should display the menaing if status column is blank then it should dispaly blank otherwise after joining iwth the lookup table it should display meaning)Hi Prazy,
using nvl also didn't solve my problem.Actually my problem is I am having a table a in which I have a column called satus, status has the values like A or I .I have one lookup called MTH_BUYSINESS_FUNCTION in which for lookup_code A I have menaing as Active and for lookup_code I meaning is Inactive.Now in table a for sttaus I have two values one A and one null Now I want to write sql which displayes the meaning for column staus.Result should be Active and null .If I am uisng 1 query which I gave u I am not able to get the 2nd row in my output.If I use 2nd query then I get duplicate rows.
Thanks ,
Amrit -
Query with Outer Join - Infocube X Infoobject
Hi,
I Have an infoobject(0account) and an infocube(Ic_accounts) in a Multicube.
I Have a Query and i need to show in this Query the accounts from infoobject(0account) that are not in infocube(ic_accounts).
How can I do this ?
ThanksIdentify a KF for which there are non-zero values for all accounts in the cube.
Create the query with Account (from MP coming from both IO and cube) and this KF. KF will have 0 values for accounts not existing in the cube. Create a condition to show only the 0 value for the KF. This should show you all the accounts in the IO which are not in the cube. -
Problem with outer joins and the class indicator/discriminator
Hello,
I am having a problem defining a query in toplink (10.1.3.3).
In the workbench, I have created a parent and 2 child descriptors. The parent is "AbstractValue", the children are "DefaultValue", classified by the discriminator 'DEF', and "OverrideValue", classified by 'OVR', both located in the same table.
Another descriptor (containing a one-on-one mapping to both a "DefaultValue", and a "OverrideValue") needs to be queried for its 'value'.
The way the query should act is: If an override value (row) exists, this one applies for that object. If an override doesn't exist, return the default value.
The query then comes down to (as I have it now):
builder.getAllowingNull("OverrideValue").getAllowingNull("value").ifNull(builder.get("DefaultValue").get("value")).equal(builder.getParameter(VALUE_PARAM));
The problem is that toplink adds the distinction for the different kind of "values" in the where clause WITHOUT checking for null values e.g. it performs an outer join, but then still checks for the discriminator value thus
....t1.ovr_id = t2.id(+) AND t2.discriminator = 'OVR' AND ...
instead of
... LEFT JOIN values t2 ON (t1.ovr_id = t2.id AND t2.discriminator = 'OVR') ...
This leads to the behaviour that the query returns ONLY the objects that have override and default values.
An overview of the queries (simplified)
Toplink, at the moment, returns only results if both override and default values exists:
SELECT t1.id
t1.def_id,
t1.ovr_id
FROM values t2,
parameter t1,
values t0
WHERE nvl(t2.value, t0.value) = 15 AND
t1.ovr_id = t2.id(+) AND t2.discriminator = 'OVR' AND
t1.def_id = t0.id AND t0.discriminator = 'DEF'
Situation Wanted:
SELECT t1.id
t1.def_id,
t1.ovr_id
FROM parameter t1
LEFT JOIN values t2 ON (t1.ovr_id = t2.id AND t2.discriminator = 'OVR')
JOIN values t0 ON (t1.def_id = t0.id AND t0.discriminator = 'DEF')
WHERE nvl(t2.value, t0.value) = 15
Anyone know if there is some statement I am missing to allow an actual outer join on descriptors containing class indicators/discriminators? A possible rewrite?
Thanks in advance,
RudyThis is a bug in TopLink's outer join support for Oracle. Currently the outer join is put in the where clause, instead of the from clause, as we do on other platforms. You might be able to fix it by changing your OraclePlatform to return false for shouldPrintOuterJoinInWhereClause().
Please log this bug on EclipseLink, or through Oracle technial support.
There is a workaround using,
descriptor.getInhertiancePolicy().setAlwaysUseOuterJoinForClassType(true);
James : http://www.eclipselink.org -
How to use common object from two tables with out join.
HI,
I have two tables called A & B In A table i have the following objects
1.weekend
2.S1(measure)
3.S2(measure)
4.S3(measure)
5.S4(measure)
And In B table i have followning columns
1.week end
2.p1(measure)
3.p2(measure)
4.p3(measure)
5.p4(measure)
Now in universe i created all the measure objects i.e.s1,s2,s3,s4,p1,p2,p3,p4 A.weekend,B.weekend.
instead of using week end two times i wnt to use only once because this is common in both table.
if i use join between these tables i am getting values fine
But With out join is there any thing to do in universe level to create common objects to use from both the tables..I tried using aggregate awareness but while reporting it is taking as two SQL.which is not synchronized.
Please help me on this ...hi,
Although Weekend column is present in both tables, by creating a single Object in Universe, Universe can identify relationship with only table referenced in Object Creation.
So, there will be no identification of relationship with other table measures.
Obviously, you need to create 2 Weekend objects in Universe (in two classes).
Case 1: You need not join these two tables in Universe. When you create 2 Queries in WEBI, automatcially Weekend objects are synchronized (if both are of same datatype)
Case 2: If you join these two tables in Universe, Obviously,
your SQL may contain Weekend from Table1, measures from Table 2
or
your SQL may contain Weekend from Table2, measures from Table 1
Finally, You need to create 2 objects in Universe. But your query may contain a single Object based on Case 2.
Regards,
Vamsee -
Generate a where clause with outer join criteria condition: (+)=
Hi,
In my search page, I use Auto Customization Criteria mode, and I build where clause by using get Criteria():
public void initSrpQuery(Dictionary[] dic, String userName) {
int dicSize = dic.length;
StringBuffer whereClause = new StringBuffer(100);
Vector parameters = new Vector(5);
int clauseCount = 0;
int bindCount = 1;
for(int i=0; i < dicSize; i++){
String itemName = (String)(dic.get(OAViewObject.CRITERIA_ITEM_NAME));
Object value = dic[i].get(OAViewObject.CRITERIA_VALUE);
String joinCondition = (String)dic[i].get(OAViewObject.CRITERIA_JOIN_CONDITION);
String criteriaCondition = (String)dic[i].get(OAViewObject.CRITERIA_CONDITION);
String criteriaDataType = (String)dic[i].get(OAViewObject.CRITERIA_DATATYPE);
String viewAttributename = (String)dic[i].get(OAViewObject.CRITERIA_VIEW_ATTRIBUTE_NAME);
String columnName = findAttributeDef(viewAttributename).getColumnNameForQuery();
if((value != null) /*&& (!("".equals((String).trim())))*/){
if(clauseCount > 0){
whereClause.append(" AND ");
whereClause.append(columnName + " " + criteriaCondition + " :");
whereClause.append(++bindCount);
parameters.addElement(value);
clauseCount++;
If I want to generate following where clause:
select
,emp.name
,emp.email
,emp.salesrep_number
,comp.name
,gs.srp_goal_header_id
,gs.status_code
,gs.start_date
,gs.end_date
from g2c_goal_shr_emp_assignments_v emp
,jtf_rs_salesreps rs
,xxg2c_srp_goal_headers_all gs
,cn_comp_plans_all comp
where 1 = 1
and rs.salesrep_id = gs.salesrep_id (+)
and gs.comp_plan_id = comp.comp_plan_id (+)
and gs.period_year (+) = :1 -- :1 p_fiscal_year
How can I generate a where clause with outer join : gs.period_year (+) = :1 ? Will I get '(+)=' from get(OAViewObject.CRITERIA_CONDITION)?
thanks
LeiIf you are using SQL-Plus or Reports you can use lexical parameters like:
SELECT * FROM emp &condition;
When you run the query it will ask for value of condition and you can enter what every you want. Here is a really fun query:
SELECT &columns FROM &tables &condition;
But if you are using Forms. Then you have to change the condition by SET_BLOCK_PROPERTY.
Best of luck! -
Problem with outer join with filter on join column
Hi,
In physical layer I have one dimension and two facts, and there's an outer join between the facts.
dim_DATE ,
fact_1 ,
fact_2
Joins:
dim_DATE inner join fact_1 on dim_DATE.DATE = fact_1.DATE
fact_1 left outer join fact_2 on fact_1.DATE = fact_2.DATE and fact_1.SOME_ID = fact_2.SOME_ID
When I run a report with a date as a filter, OBIEE executes "optimized" physical SQL:
select fact1.X, fact2.Y
from
Fact_1 left outer join on fact_1.DATE = fact_2.DATE and fact_1.SOME_ID = fact_2.SOME_ID
where Fact_1.DATE = TO_DATE('2009-05-28' , 'YYYY-MM-DD' )
and Fact_2.DATE = TO_DATE('2009-05-28' , 'YYYY-MM-DD')
The filter on Fact_2.DATE effectively replaces outer join with inner.
Is there a way to disable this "optimization", which is actually very good for inner joins, but doesn't allow outer joins?
Thanks in advance,
Alex
Edited by: AM_1 on Aug 11, 2009 8:20 AMIf you want to perform a Fact-based partitioning with OBIEE (two fact with the same dimension), you have to :
* create in your physical layer for each fact table the joins with the dimension
* create in the Business Model layer ONE star schema with ONE logical fact table containing the columns of your two physical fact table
In this way when you choose minimal one column of your fact1 and one column of your fact2, OBIEE will perform two query against each fact table/dimension, join them with an OUTER JOIN and your problem will disappear.
Cheers
Nico -
Use of db link in subquery with outer join
I have a query where i am using db link to get data from another database.
I have an outer join where i am using a subquery using the same db link but it fails gives me the error:
ORA-00991: illegal use of LONG datatype.
But the same query with inner join is not giving me the error.
Is this a limitation of Oracle or am I doing something wrong.This is an example of what i am running. That last outer join does not work c.acad_plan(+).
select count(1)
from ( select a.* from cb001_tbl a where a.strm='1800' ) a ,
( select distinct emplid,national_id,strm, acad_plan, acad_career from ps_uhcb_001@SAPRD where institution='00730') b ,
( select * from ps_acad_plan_tbl@SAPRD a
where a.institution='00730'
and a.eff_status='A'
and a.effdt=(select max(b.effdt) from ps_acad_plan_tbl@SAPRD b
where a.institution=b.institution
and a.acad_plan=b.acad_plan
and b.effdt<=to_date(20100514,'yyyymmdd'))) c
where a.stdnt_id=b.national_id (+)
and a.strm=b.strm (+)
and b.acad_plan=c.acad_plan (+) -
Help requried with outer joins
Hi All,
I neeed a query help can any one please help me getting this done,
for the below query
select trunc(assumed_time_sql) AS date1,sum(rp.rebate_due)as sum1 from mn_date_dim dd ,mn_rebate_payment rp,mn_prc_program prc,mn_structured_doc sd
where trunc(assumed_time_sql) in (TO_DATE('01-JUL-10','dd-mon-yy'),add_months(TO_DATE('01-JUL-10','dd-mon-yy'),-3),add_months(TO_DATE('01-JUL-10','dd-mon-yy'),-6),add_months(TO_DATE('01-JUL-10','dd-mon-yy'),-9))----input parameter
AND trunc(dd.assumed_time_sql)=TRUNC(rp.start_date)
AND prc.prc_program_id=rp.tiered_rebate_id
AND sd.struct_doc_id=prc.struct_doc_id
AND sd.struct_doc_id_num='M0000763'----input parameter
group by trunc(assumed_time_sql);
I am getting output as
date1 sum1
01-JAN-10 10
01-APR-10 15
01-JUL-10 20
But i want my output to be as
date1 sum1
01-JAN-10 10
01-APR-10 15
01-JUL-10 20
01-OCT-09 NULL
I have tried with outer joins but this didn't help me
Can any one please give me help in getting this done
ThanksHi,
As SB pointed out, you'd better provide tables and data in order to be helped more efficiently.
Anyway, you may want to investigate the use of NVL and/or DECODE so that you can translate NULL into valid values so they are returned to your select statement.
HTH,
Thierry
Handle: p78
Status Level: Newbie (10)
Registered: Mar 9, 2009
Total Posts: 60
Total Questions: 35 (30 unresolved) Be kind to share your helpful / correct threads with other with marking them as ANSWERED
Edited by: Urgent-IT on Feb 13, 2011 11:00 AM -
Oracle hangs on query with multiple joins
To test the sotftware from the LMS-vendor that are out partners we use virtual machines where we install Windows 2003 servers and Oracle XE
While we were testing the software I've found that a particular query with multiple unions causes the CPU of the virtual machine totally claimed by oracle
The query causes oracle to hang.
I've found that the subcomponents of the query all return 0 rows (and response all immediately) combined into a query with at least 2 unions the query hangs the system
I'm not familiar with with Database Management at all
I've read something about SGA and PGA that could be the issue and tried to increase the target for both but it doesn't seem to do anything
Some characterics
Target Current
Maximum System Global Area (SGA) Size: 380 MB 380 MB
Program Global Area (PGA) Aggregate Target: 360 MB 38 MB
Current Configuration: (SGA + PGA): 740 MB 418 MB
Tablespaces Percent Used Allocated (MB) Used (MB) Datafiles
SYSAUX 98.21% 460.00 451.75 1
SYSTEM 73.09% 510.00 372.75 1
DATA 99.13% 440.00 436.19 1
UNDO 6.48% 160.00 10.38 1
USERS 1.63% 100.00 1.63 1
sort_area_size 65536
shared_pool_reserved_size 5452595 TRUE size in bytes of reserved area of shared pool
shared_pool_size 0 TRUE size in bytes of shared pool
What other parameters are important? How could I get a good picture to see what's really going on?
Some pointers, help would be appreciated.
Regards,
RemcoBelow is the base-query that is causing the problems
SELECT /* Public - Internal learner */ r.id reg_id, i.id order_item_id, o.id order_id, o.order_no order_number, e.id person_id, format_name(e.fname , e.lname , @@005) learner_name , c.id company_id, c.name2 , ent.id entid, ctype.id ctypeid, ctype.name , i.status , items.description item_desc, substr ( i.flags , 1 , 1 ) is_conf , r.status status1, rs.description description1 , r.wlist_priority , r.reg_no , r.flags , o.status status2, o.split, null learnerViewOnly, null statusViewOnly, i.approved_status, decode(substr(r.flags,2,1),'1','true','false') isWalkIn, oa.id offering_action_id, oa.status profile_status ,c.name2 org_name ,ctype.name audience_sub_type ,items.description description ,o.order_no order_no ,orderList.description order_status ,approvalList.description approval_status ,e.fname learner_first_name ,e.lname learner_last_name FROM tpt_registration r INNER JOIN tpt_oe_order_items i ON i.reg_id = r.id INNER JOIN tpt_oe_order o ON i.order_id = o.id INNER JOIN cmt_person e ON r.student_id = e.id INNER JOIN tpt_company c ON e.company_id = c.id INNER JOIN tpt_offering_action oa on r.offering_action_id = oa.id LEFT OUTER JOIN tpt_roster_template_entry ent ON r.ros_temp_ent_id = ent.id LEFT OUTER JOIN tpt_customer_type ctype ON ent.customer_type_id = ctype.id INNER JOIN fgt_ext_sys_list_of_val rs ON to_char ( r.status ) = rs.name INNER JOIN fgt_ext_sys_list_of_val items ON to_char ( i.status ) = items.name INNER JOIN fgt_ext_sys_list_of_val orderList ON to_char ( o.status ) = orderList.name INNER JOIN fgt_ext_sys_list_of_val approvalList ON to_char(i.approved_status) = approvalList.name WHERE e.type = 100 AND r.class_id = @@001 AND r.status = nvl ( to_number(@@002) , r.status ) AND rs.locale_id = @@005 AND rs.list_id = 'sysli000000000000100' AND items.locale_id = @@005 AND items.list_id = 'sysli000000000000131' AND orderList.list_id = 'sysli000000000000129' AND orderList.locale_id = @@005 AND approvalList.list_id = 'sysli000000000000165' AND approvalList.locale_id = @@005 AND ((@@003 is null) or (@@003 is not null and r.student_id = @@003))
UNION
SELECT /* Public - External learner */ r.id reg_id, i.id order_item_id, o.id order_id, o.order_no , e.id person_id, format_name(e.fname , e.lname , @@005) , c.id company_id, c.name2 , ent.id entid, ctype.id ctypeid, ctype.name , i.status , items.description , substr ( i.flags , 1 , 1 ) is_conf , r.status status1, rs.description description1, r.wlist_priority , r.reg_no , r.flags , o.status status2, o.split, null learnerViewOnly, null statusViewOnly, i.approved_status, decode(substr(r.flags,2,1),'1','true','false') isWalkIn, oa.id offering_action_id, oa.status profile_status ,c.name2 org_name ,ctype.name audience_sub_type ,items.description description ,o.order_no order_no ,orderList.description order_status ,approvalList.description approval_status ,e.fname learner_first_name ,e.lname learner_last_name FROM tpt_registration r INNER JOIN tpt_oe_order_items i ON i.reg_id = r.id INNER JOIN tpt_oe_order o ON i.order_id = o.id INNER JOIN cmt_person e ON r.student_id = e.id INNER JOIN tpt_offering_action oa on r.offering_action_id = oa.id LEFT OUTER JOIN tpt_company c ON e.company_id = c.id LEFT OUTER JOIN tpt_roster_template_entry ent ON r.ros_temp_ent_id = ent.id LEFT OUTER JOIN tpt_customer_type ctype ON ent.customer_type_id = ctype.id INNER JOIN fgt_ext_sys_list_of_val rs ON to_char ( r.status ) = rs.name INNER JOIN fgt_ext_sys_list_of_val items ON to_char ( i.status ) = items.name INNER JOIN fgt_ext_sys_list_of_val orderList ON to_char ( o.status ) = orderList.name INNER JOIN fgt_ext_sys_list_of_val approvalList ON to_char(i.approved_status) = approvalList.name WHERE e.type = 200 AND r.class_id = @@001 AND r.status = nvl ( to_number(@@002) , r.status ) AND rs.locale_id = @@005 AND rs.list_id = 'sysli000000000000100' AND items.locale_id = @@005 AND items.list_id = 'sysli000000000000131' AND orderList.list_id = 'sysli000000000000129' AND orderList.locale_id = @@005 AND approvalList.list_id = 'sysli000000000000165' AND approvalList.locale_id = @@005 AND ((@@003 is null) or (@@003 is not null and r.student_id = @@003))
UNION
SELECT /* Public - Unassigned learner */ r.id reg_id, i.id order_item_id, o.id order_id, o.order_no , null person_id, null , null company_id, null , ent.id entidd, ctype.id ctypeid, ctype.name , i.status , items.description , substr ( i.flags , 1 , 1 ) is_conf , r.status status1, rs.description description1, r.wlist_priority , r.reg_no , r.flags , o.status status2, o.split, null learnerViewOnly, null statusViewOnly, i.approved_status, decode(substr(r.flags,2,1),'1','true','false') isWalkIn, oa.id offering_action_id, oa.status profile_status ,'' org_name ,ctype.name audience_sub_type ,items.description description ,o.order_no order_no ,orderList.description order_status ,approvalList.description approval_status ,'' learner_first_name ,'' learner_last_name FROM tpt_registration r INNER JOIN tpt_oe_order_items i ON i.reg_id = r.id INNER JOIN tpt_oe_order o ON i.order_id = o.id INNER JOIN tpt_offering_action oa on oa.id = r.offering_action_id LEFT OUTER JOIN tpt_roster_template_entry ent ON r.ros_temp_ent_id = ent.id LEFT OUTER JOIN tpt_customer_type ctype ON ent.customer_type_id = ctype.id INNER JOIN fgt_ext_sys_list_of_val rs ON to_char ( r.status ) = rs.name INNER JOIN fgt_ext_sys_list_of_val items ON to_char ( i.status ) = items.name INNER JOIN fgt_ext_sys_list_of_val orderList ON to_char ( o.status ) = orderList.name INNER JOIN fgt_ext_sys_list_of_val approvalList ON to_char(i.approved_status) = approvalList.name WHERE r.class_id = @@001 AND r.status = nvl ( to_number(@@002) , r.status ) AND r.student_id is null AND rs.locale_id = @@005 AND rs.list_id = 'sysli000000000000100' AND items.locale_id = @@005 AND items.list_id = 'sysli000000000000131' AND orderList.list_id = 'sysli000000000000129' AND orderList.locale_id = @@005 AND approvalList.list_id = 'sysli000000000000165' AND approvalList.locale_id = @@005 AND @@003 is null
UNION
SELECT /* Private - Internal learner */ r.id reg_id, i.id order_item_id, o.id order_id, o.order_no , e.id person_id, format_name(e.fname , e.lname , @@005) , c.id company_id, c.name2 , ent.id entid, ctype.id ctypeid, ctype.name , i.status , items.description , substr ( i.flags , 1 , 1 ) is_conf , r.status status1, rs.description description1 , r.wlist_priority , r.reg_no , r.flags , o.status status2, o.split, null learnerViewOnly, null statusViewOnly, i.approved_status, decode(substr(r.flags,2,1),'1','true','false') isWalkIn, oa.id offering_action_id, oa.status profile_status ,c.name2 org_name ,ctype.name audience_sub_type ,items.description description ,o.order_no order_no ,orderList.description order_status ,approvalList.description approval_status ,e.fname learner_first_name ,e.lname learner_last_name FROM tpt_registration r INNER JOIN let_pvt_offering_request pvt_offreq ON pvt_offreq.class_id = r.class_id INNER JOIN tpt_offering_action oa on oa.id = r.offering_action_id LEFT OUTER JOIN tpt_oe_order_items i ON i.part_id = pvt_offreq.id LEFT OUTER JOIN tpt_oe_order o ON i.order_id = o.id INNER JOIN cmt_person e ON r.student_id = e.id LEFT OUTER JOIN tpt_company c ON e.company_id = c.id LEFT OUTER JOIN tpt_roster_template_entry ent ON r.ros_temp_ent_id = ent.id LEFT OUTER JOIN tpt_customer_type ctype ON ent.customer_type_id = ctype.id INNER JOIN fgt_ext_sys_list_of_val rs ON to_char ( r.status ) = rs.name LEFT OUTER JOIN fgt_ext_sys_list_of_val items ON to_char ( i.status ) = items.name AND items.locale_id = @@005 AND items.list_id = 'sysli000000000000131' LEFT OUTER JOIN fgt_ext_sys_list_of_val orderList ON to_char ( o.status ) = orderList.name AND orderList.list_id = 'sysli000000000000129' AND orderList.locale_id = @@005 LEFT OUTER JOIN fgt_ext_sys_list_of_val approvalList ON to_char(i.approved_status) = approvalList.name AND approvalList.list_id = 'sysli000000000000165' AND approvalList.locale_id = @@005 WHERE e.type = 100 AND r.class_id = @@001 AND r.status = nvl ( to_number(@@002) , r.status ) AND rs.locale_id = @@005 AND rs.list_id = 'sysli000000000000100' AND ((@@003 is null) or (@@003 is not null and r.student_id = @@003))
UNION
SELECT /* Private - External learner */ r.id reg_id, i.id order_item_id, o.id order_id, o.order_no , e.id person_id, format_name(e.fname , e.lname , @@005) , c.id company_id, c.name2 , ent.id entid, ctype.id ctypeid, ctype.name , i.status , items.description , substr ( i.flags , 1 , 1 ) is_conf , r.status status1, rs.description description1 , r.wlist_priority , r.reg_no , r.flags , o.status status2, o.split, null learnerViewOnly, null statusViewOnly, i.approved_status, decode(substr(r.flags,2,1),'1','true','false') isWalkIn, oa.id offering_action_id, oa.status profile_status ,c.name2 org_name ,ctype.name audience_sub_type ,items.description description ,o.order_no order_no ,orderList.description order_status ,approvalList.description approval_status ,e.fname learner_first_name ,e.lname learner_last_name FROM tpt_registration r INNER JOIN let_pvt_offering_request pvt_offreq ON pvt_offreq.class_id = r.class_id INNER JOIN tpt_offering_action oa on r.offering_action_id = oa.id LEFT OUTER JOIN tpt_oe_order_items i ON i.part_id = pvt_offreq.id LEFT OUTER JOIN tpt_oe_order o ON i.order_id = o.id INNER JOIN cmt_person e ON r.student_id = e.id LEFT OUTER JOIN tpt_company c ON e.company_id = c.id LEFT OUTER JOIN tpt_roster_template_entry ent ON r.ros_temp_ent_id = ent.id LEFT OUTER JOIN tpt_customer_type ctype ON ent.customer_type_id = ctype.id INNER JOIN fgt_ext_sys_list_of_val rs ON to_char ( r.status ) = rs.name LEFT OUTER JOIN fgt_ext_sys_list_of_val items ON to_char ( i.status ) = items.name AND items.locale_id = @@005 AND items.list_id = 'sysli000000000000131' LEFT OUTER JOIN fgt_ext_sys_list_of_val orderList ON to_char ( o.status ) = orderList.name AND orderList.locale_id = @@005 AND orderList.list_id = 'sysli000000000000129' LEFT OUTER JOIN fgt_ext_sys_list_of_val approvalList ON to_char(i.approved_status) = approvalList.name AND approvalList.locale_id = @@005 AND approvalList.list_id = 'sysli000000000000165' WHERE e.type = 200 AND r.class_id = @@001 AND r.status = nvl ( to_number(@@002) , r.status ) AND rs.locale_id = @@005 AND rs.list_id = 'sysli000000000000100' AND ((@@003 is null) or (@@003 is not null and r.student_id = @@003)) ORDER BY 34,35,28,29,31,30,33,32 -
Please suggest a select query / sub query with out using any subprograms or
source table: Three columns ORIGIN, DESTINATION,MILES
Origin Destination Miles
Sydney Melbourne 1000
Perth Adelaide 3000
Canberra Melbounre 700
Melbourne Sydney 1000
Brisbane Sydney 1000
Perth Darwin 4000
Sydney Brisbane 1000
out put :Three columns ORIGIN, DESTINATION,MILES
Duplicate routes are to be ignored so the output is
Origin Destination Miles
Sydney Melbourne 1000
Perth Adelaide 3000
Canberra Melbounre 700
Brisbane Sydney 1000
Perth Darwin 4000
Please suggest a select query / sub query with out using any subprograms or functions/pkgs to get the out put table.Hi,
user9368047 wrote:
... Please suggest a select query / sub query with out using any subprograms or functions/pkgs to get the out put table.Why? If the most efficient way to get the results you want involves using a function, why wouldn't you use it?
Here's one way, without any functions:
SELECT a.*
FROM source_table a
LEFT OUTER JOIN source_table b ON a.origin = b.destination
AND a.destination = b.origin
AND a.miles = b.miles
WHERE b.origin > a.origin -- Not b.origin > b.origin
OR b.origin IS NULL
;If you'd care to post CREATE TABLE and INSERT statements for your sample data, then I could test this.
Edited by: Frank Kulash on Nov 6, 2012 7:39 PM
Corrected WHERE clause after MLVrown (below) -
Outer join with where clause in the universe
Hi,
I have two tables such as:
Patient Table (P) Territory Table (T)
P. Alignment ID -------------------------- T.Alignment ID
P. Patient ID T. Region
Two tables are joined on alignment ID, follow is how the data looks like
When i run the query only on Patient Table i get the following
e.g.
Select P.Patient ID, P.Alignment ID
from Patient Table (P)
Where P.Data_date=P.Latest data date
----Note that there is a Where clause here always & i get the following result
P.Patient ID P.Alignment ID
1 1a
2 2a
3 3a
4 Null
5 Null
Now when i join two tables on Alignment ID
e.g.
Select P.Patient ID, P.Alignment ID,T.Region
from Patient Table (P)
LEFT OUTER JOIN Territory Table (T)
ON P. Alignment ID = T.Alignment ID
Where P.Data_date=P.Latest data date
AND T.Data_date=T.Latest data date
Following is the result:
P.Patient ID P.Alignment ID
1 1a
2 2a
3 3a
Even with the left outer join it is not brining in the Null values , it seems that because of the WHERE clause the LEFT OUTER is working as a INNER join.
How can i get the Null rows with my join to the territory table ?
Please Advise,
Thanks,
Sheikhits not letting me atatched the excel extract but the data is simple as i shown above e.g.
Patient Table (P) Territory Table (T)
P. Alignment ID -------------------------- T.Alignment ID
P. Patient ID T. Region
Two tables are joined on alignment ID, follow is how the data looks like
When i run the query only on Patient Table i get the following
e.g.
Select P.Patient ID, P.Alignment ID
from Patient Table (P)
Where P.Data_date='01-OCT-2014'
----Note that there is a Where clause here always & i get the following result
P.Patient ID P.Alignment ID
1 1a
2 2a
3 3a
4 Null
5 Null
Now when i join two tables on Alignment ID
e.g.
Select P.Patient ID, P.Alignment ID,T.Region
from Patient Table (P)
LEFT OUTER JOIN Territory Table (T)
ON P. Alignment ID = T.Alignment ID
Where P.Data_date='01-OCT-2014'
AND T.Data_date='01-OCT-2014'
Following is the result:
P.Patient ID P.Alignment ID
1 1a
2 2a
3 3a
Now the whole issue is that the condition in the WHERE clause is making it act like a inner join and iw ant the NULL rows to appear
Sheikh -
Issue with Outer Join (Possible Bug)
Hi,
I am using Toplink 10.3.3 with oracle as db. I noticed that if I use outer joins with collections, then toplink doesnt add (+) sign to the where clause of the collection.
For e.g. for a relationship - Employee has projects, if I do an outer join on projects and also provide a where clause for projects collection, the query doesnt include the (+) sign in it.
Expression expr = builder.anyOfAllowingNone("projects").getAllowingNull("anotherOne-OneMapping").get("attr").equal("Value")
This expr goes in the where clause and TopLink does not generate (+) in the query alongside attr = "Value"
I have tried this from workbench as well as Java. Could anyone please confirm that the above scenario works? May be this is a bug in toplink !
TIA
AniI too have found a few bugs with full outer joins. Many of them have been fixed in 9iR2 though.
Like this one simple one on unpatched 9iR1: select foo1.x, foo2.x
from foo1 full outer join (select * from foo2 where x = :bindx) foo2 on (foo1.y = foo2.y)
ERROR at line 2:
ORA-00600: internal error code, arguments: [qctcte1], 0], [], [], [], [], [], []Fixed here: Hdr: 2458655 9.0.1.3.0 RDBMS 9.0.1.3.0 SQL LANGUAGE PRODID-5 PORTID-453
Abstract: ORA-600 [QCTECTE1] ON QUERY WITH FULL OUTER JOIN AND BIND VARIABLES -
Tabular form on table with no p.k
hi all
the question i'm about to ask is basic question on creating table , and as a result of that about tabular form
i have table like this
IND NUMBER(2)
COMPANY NUMBER(5)
CLM_NUM NUMBER(15)
VERSION_NUM NUMBER(2)
DATE_GET NUMBER(8)
CAR_NUMBER VARCHAR2(7)
MISS_EXPL VARCHAR2(50)
there can be more than one row with the same data. that's why i cannot do a primary key in this table.
i want to create a tabular form on this table.
the question is as follow:
1.general question not related to tabular form.
if there is table like in my case,which i cannot see that p.k can create with the columns that i have ,do i have to add column lets say : ID which contain consistent numbers
which will be the p.k ? , or is it o.k to leave the table with no p.k.
i know that in apex 1.6 is not giving an option to create table if i'm not declare a p.k , while in 3.1 it give an
option to create with no p.k
2. second question is : if i'm not doing a primary key is it possible to create a tabular form.
i know that the tabular form ask for a p.k but i did not understand if it want the specific p.k of the table.
3. if it possible(to create tabular on table not declare with tabular form) can i have a problem in the tabular form to recognize the record(row) which need to delete or update?
4. last question: again general question about creating table
is it by the accepted to create table which has no p.k but unique constraint like this
create unique constraint IND ,COMPANY,CLM_NUM,VERSION_NUM ,DATE_GET,CAR_NUMBER?
thanks for quick response!Hi Naama,
Firstly, a primary key does not necessarily have anything to do with the data on the table. In most of my tables, it is just a sequential value created from a sequence and set by a trigger. In some cases, I do have non-numeric primary keys, but these are simple text fields that can never contain duplicates (for example, country codes) and which the user can not alter.
So, I would strongly recommend that you create a primary key on your tables.
Secondly, yes, you can create unique constraints on those fields. But note that Apex will not allow you to use that many fields as a "primary key" on any form.
If you have records with the same values in all fields, without a primary key, Apex would not know which record was being updated.
Andy
Maybe you are looking for
-
Different GL accunts during GR for PO and GR for production order
Hi For posting GR for PO and GR for Production order we use movement 101 only then how we can define or e different GL accounts for both the transactions ?
-
Deploying applications to glassfish using Maven.
Hello, I am both a glassfish and maven newbie. I want to know if there's away to automatically deploy my .war in glassfish via the .pom file. (My current solution: an ant script to copy my target .war to glassfish/domains/domain1/autodeploy is not th
-
Do I need to uninstall Maverick????
Ever since the Maverick gmail fix my FCP has been crashing during export. I have background render turned off and nap turned off. I was able to export dozesns of movies with Maverick and FCP before latest update: Tue Nov 12 18:00:19 2013 panic(cpu
-
What does it take to create a vaild .P12 certificate for Flash Builder to use when running Adobe Extension Manager. I have a SSL cert file but it is not a .P12 file. Thanks
-
Cannot install WindowsAzureStorageEmulator.3.2
Hi everyone, I just upgraded form win7 to win 8.1. Everything went fine, except installing Windows Azure .Net Sdk for Visual Studio 2013 Ultimate Update2. I've tried it through the platform installer. I also have SQL 2012 express + management tools i