Help need for Outer Join Query Mysterious Query...
I have two table parent tablea and child tableb
Now
tableb has field by name table_id,keyword_name,keyword_value
tablea has field by name
table_id,table_name
I need a query which would retrieve union of this two set...(for table_name)
1)all table_name having keyword_name='abc' and value=12
2)all the table_name that does not have 'abc' as keyword in tableb.....
Please let me know how it can be done....
Ok then, try this.
select
a.table_name
from
tablea a, tableb b
where
a.table_id = b.table_id
and b.keyword_name = 'abc'
and b.value = 12
union
select
c.table_name
from
tablea c
where
not exists (select 1 from tableb d
where d.table_id = c.table_id
and d.keyword_name = 'abc'
) ;To get a faster answer and avoid wrong guesses, I always find it helpful to show sample data and sample output when asking a SQL question. For example:
TableA -----------------
table_id table_name
1 AAA
2 BBB
3 CCC
4 DDD
5 EEE
TableB -----------------
table_id keyword_name value
1 abc 12
1 def 23
2 abc 13
4 def 12
5 abc 13
5 def 12
Desired output of query: -----------------
AAA
CCC
DDD
Similar Messages
-
Hi,
The follwing is my query
select imdsrequest.*,request_material.*,request.request_num from imdsrequest join request_material on
(imdsrequest.REQUEST_ID = request_material.REQUEST_ID)
join REQUEST on (request.request_id = request_material.associated_request_id)
it executes fine. But i want to re-write this query using outer join . on the above query i am using ON condition for matching the columns.
can any one help me to restructure this with outer join so that i can give all the conditions using WHERE clause .
Edited by: 936693 on Jul 3, 2012 7:12 AM
Edited by: 936693 on Jul 3, 2012 7:13 AMHi,
Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using.
See the forum FAQ {message:id=9360002}
936693 wrote:
Hi Folks ,
Thanks for the reply. i don't want to use "ON" condition. So can you please show me some example based on my requirement .
i will have to use where condition instead of on and have to use outer joins where and all require, please guide me .Why don't you want to use "ON"?
Are you using Oracle 8 (or earlier)? Always say what version of Oracle you're using.
Is this part of a homework assignment, where the teacher specifically said not to use ON? Then post the exact question and instructions. It would help if you gave a little context (what was being taught in the most recent lesson) so we can give you a better answer.
The only ways to avoid "ON" are
(1) don't join any tables
(2) do a CROSS JOIN
(3) use the notation
If an outer join is appropriate for your problem, then I don't recommend any of the above. -
This is the sample piece of code in oracle which I am trying to convert it to ANSI join kindly help all the in_ and P_ and v_ are coming as a in parameter
select *
FROM fxrates_v fx1
WHERE fx1.fx_close(+) = in_fx_close AND
fx1.fxrate_currency (+) = decode (v_agree_type, 'L', upper(v_pledge_leh_unsec_curr) ,
'C', upper(v_pledge_cp_unsec_curr),
decode(sign(v_pre_mrgn_val), -1, upper(v_pledge_leh_unsec_curr),
upper(v_pledge_cp_unsec_curr)))/Michael I think your one is not equivalent to the OP's one.
Let's see an example on EMP:
SQL> select * from emp
2 where comm(+) = 300;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
SQL> select * from emp
2 where comm(+) = null;
no rows selected
SQL> select * from emp right outer join dual on comm = 300;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO D
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30 X
SQL> select * from emp right outer join dual on comm = null;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO D
XIf you add the right outer join on dual and the input parameter is null you extract an all nulls row.
But the original query doesn't behave this way, the .(+) symbols have no effect on the result either if the input parameter is not null and if it is null...
This is why I simply ignored them in my re-arrangement...
So I think you can't convert the original query in ANSI sql preserving the behaviour...
Am I missing something?
Max
http://oracleitalia.wordpress.com -
help needed for writing query
i have the following tables(with data) as mentioned below
FK*-foregin key (SUBJECTS)
FK**-foregin key (COMBINATION)
1)SUBJECTS(table name)
SUB_ID(NUMBER) SUB_CODE(VARCHAR2) SUB_NAME (VARCHAR2)
2 02 Computer Science
3 03 Physics
4 04 Chemistry
5 05 Mathematics
7 07 Commerce
8 08 Computer Applications
9 09 Biology
2)COMBINATION
COMB_ID(NUMBER) COMB_NAME(VARCHAR2) SUB_ID1(NUMBER(FK*)) SUB_ID2(NUMBER(FK*)) SUB_ID3(NUMBER(FK*)) SUBJ_ID4(NUMBER(FK*))
383 S1 9 4 2 3
384 S2 4 2 5 3
---------I actually designed the ABOVE table also like this
3) a)COMBINATION
COMB_ID(NUMBER) COMB_NAME(VARCHAR2)
383 S1
384 S2
b)COMBINATION_DET
COMBDET_ID(NUMBER) COMB_ID(FK**) SUB_ID(FK*)
1 383 9
2 383 4
3 383 2
4 383 3
5 384 4
6 384 2
7 384 5
8 384 3
Business rule: a combination consists of a maximum of 4 subjects (must contain)
and the user is less relevant to a COMB_NAME(name of combinations) but user need
the subjects contained in combinations
i need the following output
COMB_ID COMB_NAME SUBJECT1 SUBJECT2 SUBJECT3 SUBJECT4
383 S1 Biology Chemistry Computer Science Physics
384 S2 Chemistry Computer Science Mathematics Physics
or even this is enough(what i actually needed)
COMB_ID subjects
383 Biology,Chemistry,Computer Science,Physics
384 Chemistry,Computer Science,Mathematics,Physics
you can use any of the COMBINATION table(either (2) or (3))
and i want to know
1)which design is good in this case
(i think SUB_ID1,SUB_ID2,SUB_ID3,SUB_ID4 is not a
good method to link with same table but if 4 subjects only(and must) comes
detail table is not neccessary )
now i am achieving the result by program-coding in C# after getting the rows from oracle
i am using oracle 9i (also ODP.NET)
i want to know how can i get the result in the stored procedure itsef.
2)how it could be designed in any other way.
any help/suggestion is welcome
thanks for your time --PradeeshWell I forgot the table-alias, here now with:
SELECT C.COMB_ID
, C.COMB_NAME
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID1) AS SUBJECT_NAME1
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID2) AS SUBJECT_NAME2
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID3) AS SUBJECT_NAME3
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID4) AS SUBJECT_NAME4
FROM COMBINATION C;
As you need exactly 4 subjects, the columns-solution is just fine I would say. -
Restriction to Left Outer Joins in PS Query
Hello I am trying to do Left Outer JOin in PS QUERY. I need to do dept tbl, job code tbl and locatable as left outer joins with JOB Table. Looks like in PS QUERY there is a error message saying as below. Can someone has any workaround to achieve this in PS QUERY. I know I can create a View and use that in PS QUERY but BUsiness Users are dependent on IT, so that doesn't work. Also, adding JOB table multiple times works but I am looking for better solution if anyone had come accorss working through PS QUERY Outer JOins.
Windows Internet Explorer
Left outer joins must be joined to the last record in the query. (139,290)
OK
Thanks,
SC.Hi Mike,
According to your description, you want to improve the performance for your DAX query in SQL Server Analysis Service Tabular model, right? Here is a white paper describes strategies and specific techniques for getting the best performance from your tabular
models, including processing and partitioning strategies, DAX query tuning, and server tuning for specific workloads.
http://msdn.microsoft.com/en-us/library/dn393915.aspx
Since this is a complex DAX query, from a support perspective this is really beyond what we can do here in the forums. If you cannot determine your answer here or on your own, consider opening a support case with Microsoft. Visit this link to see the various
support options that are available to better meet your needs:
http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone
Regards,
Charlie Liao
TechNet Community Support -
I have written the below query, our requirement is, Some employees have "Transport Allowance" but not "Project Allowance". For this, I tried to use OUTER JOIN with this query. But this query takes long time and failed. The following query works fine if the employee has both "Transport Allowance" and "Project Allowance" (without outer join) Now, I also need to retrieve the employees who have "Transport Allowance" but not "Project Allowance". How can I retrieve it?
SELECT DISTINCT papf.employee_number
, peev.screen_entry_value Transport_Allowance
,peev1.screen_entry_value Project_Allowance
FROM apps.per_all_people_f papf
,apps.per_all_assignments_f paaf
,apps.pay_element_types_x petf
,apps.pay_element_types_x petf1
,apps.pay_element_types_x petf2
,apps.pay_element_entries_f peef
,apps.pay_element_entries_f peef1
,apps.pay_element_entries_f peef2
,apps.pay_element_entry_values_x peev
,apps.pay_element_entry_values_x peev1
,apps.pay_element_entry_values_x peev2
,apps.pay_input_values_x pivf
,apps.pay_input_values_x pivf1
,apps.pay_input_values_x pivf2
WHERE
papf.person_id = paaf.person_id
AND paaf.assignment_id = peef.assignment_id
AND paaf.assignment_id = peef1.assignment_id
AND paaf.business_group_id = papf.business_group_id
--Transport Allowance
AND peef.element_entry_id = peev.element_entry_id
AND petf.element_Name = 'Transport Allowance'
AND pivf.element_type_id =petf.element_type_id
AND pivf.name = 'Allowance'
AND peev.input_value_id= pivf.input_value_id
--Project Allowance
AND peef1.element_entry_id = peev1.element_entry_id
AND petf1.element_Name = "Project Allowance'
AND pivf1.element_type_id = petf1.element_type_id
AND pivf1.name = 'Allowance'
AND peev1.input_value_id = pivf1.input_value_id
AND (SYSDATE BETWEEN peev.effective_start_date AND peev.effective_end_date)
AND (SYSDATE BETWEEN peev1.effective_start_date AND peev1.effective_end_date)
AND (SYSDATE BETWEEN papf.effective_start_date AND papf.effective_end_date)
ORDER BY papf.employee_number
Thanks in advance.I am using sames tables with alias to retrieve the columns values from the same table.
Here is my query.
SELECT DISTINCT papf.employee_number
, peev.screen_entry_value Transport_Allowance
,peev1.screen_entry_value Project_Allowance
FROM apps.per_all_people_f papf
,apps.per_all_assignments_f paaf
,apps.pay_element_types_x petf
,apps.pay_element_types_x petf1
,apps.pay_element_entries_f peef
,apps.pay_element_entries_f peef1
,apps.pay_element_entry_values_x peev
,apps.pay_element_entry_values_x peev1
,apps.pay_input_values_x pivf
,apps.pay_input_values_x pivf1
WHERE
papf.person_id = paaf.person_id
AND paaf.assignment_id = peef.assignment_id
AND paaf.assignment_id = peef1.assignment_id
AND paaf.business_group_id = papf.business_group_id
--Transport Allowance
AND peef.element_entry_id = peev.element_entry_id
AND petf.element_Name = 'Transport Allowance'
AND pivf.element_type_id =petf.element_type_id
AND pivf.name = 'Allowance'
AND peev.input_value_id= pivf.input_value_id
--Project Allowance
AND peef1.element_entry_id = peev1.element_entry_id
AND petf1.element_Name = "Project Allowance'
AND pivf1.element_type_id = petf1.element_type_id
AND pivf1.name = 'Allowance'
AND peev1.input_value_id = pivf1.input_value_id
AND (SYSDATE BETWEEN peev.effective_start_date AND peev.effective_end_date)
AND (SYSDATE BETWEEN peev1.effective_start_date AND peev1.effective_end_date)
AND (SYSDATE BETWEEN papf.effective_start_date AND papf.effective_end_date)
ORDER BY papf.employee_number
Thanks in advance. -
Color management help needed for adobe CS5 and Epson printer 1400-Prints coming out too dark with re
Color management help needed for adobe CS5 and Epson printer 1400-Prints coming out too dark with reddish cast and loss of detail
System: Windows 7
Adobe CS5
Printer: Epson Stylus Photo 1400
Paper: Inkjet matte presentation paper with slight luster
Installed latest patch for Adobe CS5
Epson driver up to date
After reading solutions online and trying them for my settings for 2 days I am still unable to print what I am seeing on my screen in Adobe CS5. I calibrated my monitor, but am not sure once calibration is saved if I somehow use this setting in Photoshop’s color management.
The files I am printing are photographs of dogs with lots of detail I digitally painted with my Wacom tablet in Photoshop CS5 and then printed with Epson Stylus 1400 on inkjet paper 20lb with slight luster.
My Printed images lose a lot of the detail & come out way to dark with a reddish cast and loss of detail when I used these settings in the printing window:
Color Handling: Photoshop manages color, Color management -ICM, OFF no color adjustment.
When I change to these settings in printer window: Color Handling: Printer manages color. Color management- Color Controls, 1.8 Gamma and choose Epson Standard it prints lighter, but with reddish cast and very little detail and this is the best setting I have used so far.
Based on what I have read on line, I think the issue is mainly to do with what controls are set in the Photoshop Color Settings window and the Epson Printer preferences. I have screen images attached of these windows and would appreciate knowing what you recommend I enter for each choice.
Also I am confused as to what ICM color management system to use with this printer and CS5:
What is the best ICM to use with PS CS5 & the Epson 1400 printer? Should I use the same ICM for both?
Do I embed the ICM I choose into the new files I create?
Do I view all files in the CS5 workspace in this default ICM?
Do I set my monitor setting to the same ICM?
If new file opens in CS5 workspace and it has a different embedded profile than my workspace, do I convert it?
Do I set my printer, Monitor and PS CS5 color settings to the same ICM?
Is using the same ICM for all devices what is called a consistent workflow?
I appreciate any and all advice that can be sent my way on this complicated issue. Thank you in advance for your time and kind help.It may be possible to figure out by watching a Dr.Brown video on the subject of color printing. Adobe tv
I hope this may help............... -
How to make outer join in Sub Query?
Hi!
I'm facing one problem. Can anyone tell me - how to make outer join in sub query?
I'm pasting one sample code -
select e.empno, e.ename,e.job,e.sal,d.deptno,d.dname
from d_emp e, d_dept d
where e.deptno(+) = (
case
when d_dept.deptno = 10
then
select deptno
from d_dept
where dname = 'SALES'
else
d_dept.deptno
end
SQL>
ERROR at line 15:
ORA-01799: a column may not be outer-joined to a subqueryHow to resolve this issue?
Regards.And any luck with this?
SQL> with emp as
2 (select 100 empno, 'Abcd' ename, 1000 sal, 10 deptno from dual
3 union all
4 select 101 empno, 'RRR' ename, 2000 sal, 20 deptno from dual
5 union all
6 select 102 empno, 'KKK' ename, 3000 sal, 30 deptno from dual
7 union all
8 select 103 empno, 'PPP' ename, 4000 sal, 10 deptno from dual
9 )
10 ,dept as
11 (select 10 deptno, 'FINANCE' dname from dual
12 union all
13 select 20 deptno, 'SALES' dname from dual
14 union all
15 select 30 deptno, 'IT' dname from dual
16 union all
17 select 40 deptno, 'HR' dname from dual
18 )
19 select e.empno, e.ename, e.sal, d.deptno, d.dname
20 from emp e,
21 (select decode(a.deptno, 10, b.deptno, a.deptno) deptno, decode(a.deptno, 10, b.dname, a.dname) dname
22 from dept a, (select deptno, dname
23 from dept
24 where dname = 'SALES'
25 ) b
26 ) d
27 where e.deptno(+) = d.deptno
28 /
EMPNO ENAM SAL DEPTNO DNAME
101 RRR 2000 20 SALES
101 RRR 2000 20 SALES
102 KKK 3000 30 IT
40 HR
SQL> Cheers
Sarma. -
File missing (file\BCD error code 0Xc0000034 help need for work!
file missing (file\BCD error code 0Xc0000034 help need for work! what can i do?
have an p 2000 notebook pcHi bobkunkle, welcome to the HP Forums. I understand you cannot boot passed the error you are receiving.
What is the model or product number of your notebook? What version of Windows is installed?
Guide to finding your product number
Which Windows operating system am I running?
TwoPointOh
I work on behalf of HP
Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
Click the “Kudos, Thumbs Up" on the bottom to say “Thanks” for helping! -
Is there a way to make Crystal Reports XI not generate the {oj ..... syntax for outer joins?
In Crystal Reports 8, you could do a registry change to keep CR from using oj, but that doesn't seem to work on CR XI (or I don't know where to make the registry change)
Outer Join Escape Sequence builds the syntax for ODBC drivers using the outer join syntax in its SQL syntax.
Use Regedit on the problem client machine add following keys:
STEP 1........For Crystal Reports 9: HKEY_CURRENT_USER\Software\Crystal Decisions\9.0\Crystal Reports\Database\QueryBuilder\OuterJoinEscSeq
<<<OR>>>
...................For Crystal Reports 10:HKEY_CURRENT_USER\Software\Crystal Decisions\10.0\Crystal Reports\Database\QueryBuilder\OuterJoinEscSeq
STEP 2........"MSOuterJoinEscSeq"= "insert your ODBC driver name here": List of the drivers that support Microsoft ODBC {oj ..} join escape sequence.
"NoOuterJoinEscSeq"= "insert your ODBC driver name here": List of the drivers that do not support any join escape sequence.
For example...
MSOuterJoinEscSeq = "UVODBC"
Outer Join Escape Sequence builds the syntax for ODBC drivers using the outer join syntax in its SQL syntax.
Use Regedit on the problem client machine add following keys:
STEP 1........For Crystal Reports 9: HKEY_CURRENT_USER\Software\Crystal Decisions\9.0\Crystal Reports\Database\QueryBuilder\OuterJoinEscSeq
<<<OR>>>
...................For Crystal Reports 10:HKEY_CURRENT_USER\Software\Crystal Decisions\10.0\Crystal Reports\Database\QueryBuilder\OuterJoinEscSeq
STEP 2........"MSOuterJoinEscSeq"= "insert your ODBC driver name here": List of the drivers that support Microsoft ODBC {oj ..} join escape sequence.
"NoOuterJoinEscSeq"= "insert your ODBC driver name here": List of the drivers that do not support any join escape sequence.
For example...
MSOuterJoinEscSeq = "UVODBC"
Help need for force to signout All session ! how...
hi
help need for force to signout All session ! how ??
Solved!
Go to Solution.
Hi and welcome to the Skype Community,
To force a signout of all instances your Skype is signed into please change your password: https://support.skype.com/en/faq/FA95/how-do-i-change-my-password
Follow the latest Skype Community News
↓ Did my reply answer your question? Accept it as a solution to help others, Thanks. ↓
hello ,
I am a beginner in terms of writing sql queries. I hope some body can help me out.
I have two tables
mysql> desc user_group_t;
---------------------------------------------------+
| Field | Type | Null | Key | Default | Extra |
---------------------------------------------------+
| userAccountId | char(8) | | PRI | | |
| groupId | char(8) | | PRI | | |
---------------------------------------------------+
2 rows in set (0.00 sec)
mysql> desc group_t;
---------------------------------------------------+
| Field | Type | Null | Key | Default | Extra |
---------------------------------------------------+
| id | char(8) | | PRI | | |
| name | char(50) | YES | | NULL | |
| email | char(100) | YES | | NULL | |
| description | char(254) | YES | | NULL | |
| parentId | char(8) | YES | | NULL | |
| creatorId | char(8) | YES | | NULL | |
| createDate | char(20) | YES | | NULL | |
| updateDate | char(20) | YES | | NULL | |
| updatorId | char(8) | YES | | NULL | |
---------------------------------------------------+
9 rows in set (0.00 sec)
what I want is list of all groups with id,name and #of members(which is the # of rows in the user_group_t for any given id). Importantly I need the groups with 0 members also to be listed. In short my output should contain exactly the same number of rows as in group_t table with an additional column indicating # of members for that group.
Any help would be greatly appreciated.
Thanks in Advance.
-Vasanth
Thanks Donald,
Actually I figured it out, with the following query:
select id,name,sum(if(groupid is not null,1,0)) as members from group_t left join user_group_t on id=groupid group by id;
I tried your solution, but mysql says there is an error at '+' . Anyway I modified your solution to the one below and it worked.
select a.id, a.name, count(b.groupid) from group_t a left join user_group_t b on a.id=b.groupid group by a.id, a.name;
I tried that before but then I used Count(*) instead of count on groupid. Your solution is elagant and I will go with yours.
Thanks again.
Vasanth
Query help needed for querybuilder to use with lcm cli
Hi,
I had set up several queries to run with the lcm cli in order to back up personal folders, inboxes, etc. to lcmbiar files to use as backups. I have seen a few posts that are similar, but I have a specific question/concern.
I just recently had to reference one of these back ups only to find it was incomplete. Does the query used by the lcm cli also only pull the first 1000 rows? Is there a way to change this limit somwhere?
Also, since when importing this lcmbiar file for something 'generic' like 'all personal folders', pulls in WAY too much stuff, is there a better way to limit this? I am open to suggestions, but it would almost be better if I could create individual lcmbiar output files on a per user basis. This way, when/if I need to restore someone's personal folder contents, for example, I could find them by username and import just that lcmbiar file, as opposed to all 3000 of our users. I am not quite sure how to accomplish this...
Currently, with my limited windows scripting knowledge, I have set up a bat script to run each morning, that creates a 'runtime' properties file from a template, such that the lcmbiar file gets named uniquely for that day and its content. Then I call the lcm_cli using the proper command. The query within the properties file is currently very straightforward - select * from CI_INFOOBJECTS WHERE SI_ANCESTOR = 18.
To do what I want to do...
1) I'd first need a current list of usernames in a text file, that could be read (?) in and parsed to single out each user (remember we are talking about 3000) - not sure the best way to get this.
2) Then instead of just updating the the lcmbiar file name with a unique name as I do currently, I would also update the query (which would be different altogether): SELECT * from CI_INFOOBJECTS where SI_OWNER = '<username>' AND SI_ANCESTOR = 18.
In theory, that would grab everything owned by that user in their personal folder - right? and write it to its own lcmbiar file to a location I specify.
I just think chunking something like this is more effective and BO has no built in back up capability that already does this. We are on BO 4.0 SP7 right now, move to 4.1 SP4 over the summer.
Any thoughts on this would be much appreciated.
thanks,
Missy
Just wanted to pass along that SAP Support pointed me to KBA 1969259 which had some good example queries in it (they were helping me with a concern I had over the lcmbiar file output, not with query design). I was able to tweak one of the sample queries in this KBA to give me more of what I was after...
SELECT TOP 10000 static, relationships, SI_PARENT_FOLDER_CUID, SI_OWNER, SI_PATH FROM CI_INFOOBJECTS,CI_APPOBJECTS,CI_SYSTEMOBJECTS WHERE (DESCENDENTS ("si_name='Folder Hierarchy'","si_name='<username>'"))
This exports inboxes, personal folders, categories, and roles, which is more than I was after, but still necessary to back up.. so in a way, it is actually better because I have one lcmbiar file per user - contains all their 'personal' objects.
So between narrowing down my set of users to only those who actually have saved things to their personal folder and now having a query that actually returns what I expect it to return, along with the help below for a job to clean up these excessive amounts of promotion jobs I am now creating... I am all set!
Hopefully this can help someone else too!
Thanks,
missy
Need help further tuning view source for outer join
I have been working on tuning views for use in Discoverer for some time, and I have greatly improved upon what was there, but it is still not where I need it to be. There are 2 views the users join together in Discoverer - one for contract lines, and one for contract flexfields. Run as a 1 to 1 join on contract number, performance is great. However, as soon as I have an outer join on flexfields, the performance is awful. We are talking a difference of under a minute to hours and hours. I have to be able to perform an outer join because there can be contracts without flexfields. Can anyone suggest an alternative method to get the data or further tuning? I will paste both the contract lines and contract flexfields source - I have tuned the flexfields but have done nothing to date with the lines.
CREATE OR REPLACE VIEW XXDBD_CONTRACT_FLEXFIELDS AS
SELECT core.contract_id, core.service_id, core.contract_number, core.service_line, core.service, core.product_line, core.equipment, core.UL_Certificate_And_End_Date, core.MAF, core.Termination_Penalty_Percentage, core.multi_year, core.multi_year_effective_dates, core.terms_multi_year, core.SerLineRenPricingMethod, core.ren_line_change, core.zone, core.add_invoice_display, core.add_subgrouping, re.diebold_price, attr.coverage_hours, attr.reaction_times, attr.resolution_times, attr.repair_times, tr.performance_requirement, attr.penalty, attr.penalty_amount, attr.penalty_bonus, attr.mon_break_start, attr.mon_break_end, attr.tues_break_start, attr.tues_break_end, attr.wed_break_start, attr.wed_break_end, attr.thu_break_start, attr.thu_break_end, attr.fri_break_start, attr.fri_break_end, attr.sat_break_start, attr.sat_break_end, attr.sun_break_start, attr.sun_break_end, attr.split_covering, attr.cash_handling
FROM (SELECT aa.ID Contract_id,
aa.contract_number,
dd.id Service_ID ,
dd.cle_id dd_cle_id,
dd.line_number service_line,
xxdbd_Disco_Service_Contract.GetServNameInv
(dd.id) Service,
dd.line_number ||'.'||ee.line_number Product_Line,
xxdbd_Disco_Service_Contract.GetEqpNoInvoice(ee.id)
Equipment,
DECODE(dd.attribute_category,'Service Contracts',
NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_50_CHARS', dd.attribute1),dd.attribute1),'') UL_Certificate_And_End_Date,
dd.attribute2 MAF,
DECODE(dd.attribute_category,'Service Contracts',NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_NUMERIC', dd.attribute3),dd.attribute3),'') Termination_Penalty_Percentage,
DECODE(dd.attribute_category,'Service Contracts', DECODE(NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_MULTIYEAR', dd.attribute5),dd.attribute5),
'N','No Multi-Year',
'Y','Multi-Year, Years not Known',
'Y1','Multi-Year for 1 Year',
'Y2','Multi-Year for 2 Year',
'Y3','Multi-Year for 3 Year',
'Y4','Multi-Year for 4 Year',
'Y5','Multi-Year for 4 Year',dd.attribute5),'')Multi_Year,
dd.attribute4 Multi_Year_Effective_Dates,
DECODE(dd.attribute_category,'Service Contracts', NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_450_CHARS', dd.attribute9),dd.attribute9),'') Terms_Multi_Year,
DECODE(dd.attribute_category,'Service Contracts', DECODE(NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_RENEWAL_PRICING', dd.attribute6),dd.attribute6),
'MP', 'DBD Markup Percent',
'CP', 'DBD Contract Price',
'AI', 'DBD Amount Increase',
'AD', 'DBD Amount Decrease',
'TA', 'DBD Target Amount',
'FR', 'DBD Flat Rate',dd.attribute6),'') SerLineRenPricingMethod,
DECODE(dd.attribute_category,'Service Contracts', NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_NUMERIC', dd.attribute7),dd.attribute7),'') Ren_Line_Change,
DECODE(dd.attribute_category,'Service Contracts', DECODE(NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_ZONE', dd.attribute8),dd.attribute8),
'DNA1','DNA Zone 1',
'DNA2','DNA Zone 2',
'DNA3','DNA Zone 3',
'BRAZIL1','Brazil Zone 1 (50 KM)',
'BRAZIL2','Brazil Zone 2 (80 KM)',
'BRAZIL3','Brazil Zone 3 (200 KM)',dd.attribute8),'')Zone,
DECODE(dd.attribute11, 'N','None','SC','Sub Component', 'SN', 'Serial Number', 'SNSC', 'Serial Number and Sub-Component') Add_Invoice_Display,
DECODE(dd.attribute10, 'SI','Service Item', 'CP','Covered Product', 'PC','Product Category') Add_SubGrouping,
dd.attribute12 Diebold_Price,
ee.id ee_id,
ee.cle_id ee_cle_id
FROM okc_k_headers_b aa,
okc_k_lines_b dd,
okc_k_lines_b ee
-- xxdbd_temp_flex_contract tfc
WHERE aa.id = dd.DNZ_CHR_ID
AND dd.CLE_ID IS NULL
AND dd.id = ee.cle_id
AND ee.DNZ_CHR_ID = aa.id
AND ee.LSE_ID =9
AND dd.LSE_ID =1
-- and aa.contract_number = 'NL0000014'
-- and aa.contract_number in (select contract_number from xxdbd_flex_contract)
-- AND tfc.contract_number = aa.contract_number
) core,
(SELECT h.contract_number,
DECODE(l.attribute_category,
'Coverage Break', xxdbd_get_sib_cont_id(xxdbd_get_parent_cle_id(l.cle_id,2)),
'Business Process',xxdbd_get_sib_cont_id(xxdbd_get_parent_cle_id(l.cle_id,1)),
'Coverage Template Header',xxdbd_get_sib_cont_id(l.cle_id),
'Transaction Type', xxdbd_get_sib_cont_id(xxdbd_get_parent_cle_id(l.cle_id,2)),null) ee_id,
DECODE(l.attribute_category, 'Business Process', l.attribute1) Coverage_Hours,
DECODE(l.attribute_category, 'Business Process', l.attribute2) Reaction_Times,
DECODE(l.attribute_category, 'Business Process', l.attribute3) Resolution_Times,
DECODE(l.attribute_category, 'Business Process', l.attribute4) Repair_Times,
DECODE(l.attribute_category, 'Business Process', DECODE(l.attribute5,
'RA', 'REACTION'
, 'RS', 'RESOLUTION'
, 'RR', 'REACTION & RESOLUTION'
, 'NR', 'NO REQUIREMENT',
l.attribute5)) Performance_Requirement,
DECODE(l.attribute_category, 'Coverage Template Header', l.attribute1) Penalty,
DECODE(l.attribute_category, 'Coverage Template Header', l.attribute2) Penalty_Amount,
DECODE(l.attribute_category, 'Coverage Template Header', l.attribute3) Penalty_Bonus,
DECODE(l.attribute_category, 'Coverage Break', l.attribute1) Mon_Break_Start,
DECODE(l.attribute_category, 'Coverage Break', l.attribute2) Mon_Break_End,
DECODE(l.attribute_category, 'Coverage Break', l.attribute3) Tues_Break_Start,
DECODE(l.attribute_category, 'Coverage Break', l.attribute4) Tues_Break_End,
DECODE(l.attribute_category, 'Coverage Break', l.attribute5) Wed_Break_Start,
DECODE(l.attribute_category, 'Coverage Break', l.attribute6) Wed_Break_End,
DECODE(l.attribute_category, 'Coverage Break', l.attribute7) Thu_Break_Start,
DECODE(l.attribute_category, 'Coverage Break', l.attribute8) Thu_Break_End,
DECODE(l.attribute_category, 'Coverage Break', l.attribute9) Fri_Break_Start,
DECODE(l.attribute_category, 'Coverage Break', l.attribute10) Fri_Break_End,
DECODE(l.attribute_category, 'Coverage Break', l.attribute11) Sat_Break_Start,
DECODE(l.attribute_category, 'Coverage Break', l.attribute12) Sat_Break_End,
DECODE(l.attribute_category, 'Coverage Break', l.attribute13) Sun_Break_Start,
DECODE(l.attribute_category, 'Coverage Break', l.attribute14) Sun_Break_End,
DECODE(l.attribute_category, 'Transaction Type', l.attribute1) Split_Covering,
DECODE(l.attribute_category, 'Transaction Type', l.attribute2) Cash_Handling
from okc_k_lines_b l , okc_k_headers_b h--, xxdbd_temp_flex_contract tfc
where l.attribute_category in ('Coverage Break', 'Business Process', 'Coverage Template Header','Transaction Type')
and h.id = l.dnz_chr_id
-- and h.contract_number in (select contract_number from xxdbd_flex_contract)
-- and tfc.contract_number = h.contract_number
) attr
where core.ee_id = attr.ee_id (+)
and core.contract_number = attr.contract_number (+);
create or replace view xxdbd_contract_lines as
select aa.id Contract_id,
bb.id Service_id,
aa.CONTRACT_NUMBER,
F1.USER_NAME Created_By,
F2.USER_NAME LastUpdated_By,
bb.LINE_NUMBER Service_Line_No,
bb.LINE_NUMBER ||'.'|| cc.LINE_NUMBER Product_Line_No,
xxdbd_Disco_Service_Contract.GetServNameInv(bb.id) Service,
xxdbd_Disco_Service_Contract.GetServDescInv(bb.id) Service_Desc,
xxdbd_Disco_Service_Contract.GetServicePrice(bb.id) Service_Price,
bb.PRICE_UNIT Service_List_Price,
bb.CURRENCY_CODE,
aa.SCS_CODE Contract_Type,
bb.STS_CODE Service_Status,
bb.TRN_CODE Term_Code,
bb.START_DATE Service_start,
bb.END_DATE Service_end,
TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(Null, bb.id, 'OKX_BILLTO' )) SERVICE_BillToSite,
xxdbd_Disco_Service_Contract.GetLocAccount(TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(Null, bb.id, 'OKX_BILLTO' ))) Bill_Account,
xxdbd_Disco_Service_Contract.GetLocation(TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(NULL, bb.id, 'OKX_BILLTO' ))) Service_BillTo,
TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(NULL, bb.id, 'OKX_SHIPTO' )) SERVICE_ShipToSite ,
xxdbd_Disco_Service_Contract.GetLocation(TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(NULL, bb.id, 'OKX_SHIPTO' ))) Service_Ship_To,
xxdbd_Disco_Service_Contract.GetLocAccount(TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(NULL, bb.id, 'OKX_SHIPTO' ))) Ship_Account,
bb.DATE_RENEWED,
bb.DATE_TERMINATED,
cc.START_DATE Eqp_Start,
cc.END_DATE Eqp_End,
xxdbd_Disco_Service_Contract.GetEqpNoInvoice(cc.id) Eqp_No,
xxdbd_Disco_Service_Contract.GetEqpDescInvoice(cc.ID) Eqp_Desc,
xxdbd_Disco_Service_Contract.GetEqpQuantityInvoice(cc.id) Eqp_Quan,
xxdbd_Disco_Service_Contract.GetEqpSerialNoInvoice(cc.id) Eqp_Serial,
xxdbd_Disco_Service_Contract.GetCustomerCt(aa.id, bb.id) Cust_Contact,
DD.ORGANIZATION_ID,
dd.INSTALL_ADDRESS,
dd.INSTALL_DATE,
dd.INSTALL_SITE_ID INSTALL_SITE_USE_ID,
dd.PARTY_SITE_NAME INSTALL_SITE_NAME,
dd.PARTY_SITE_NUMBER INSTALL_SITE_NUMBER
,cii.inventory_item_id
,cii.inv_master_organization_id
,aa.authoring_org_id
,cc.id equipment_id
,TO_NUMBER(replace(bb.attribute12,',','')) annual_contract_amt
,ou.name operating_unit
,ou.organization_id operating_unit_id
,substr(xxdbd_ra_utility.Get_BusinessProcess(cc.cle_id),1,100) business_process
,cii.instance_id
,cii.instance_number
from okc_k_headers_b aa
,okc_k_lines_b bb
,okc_k_lines_b cc
,fnd_user f1
,fnd_user f2
,csi_item_instances cii
,okc_k_items items
,hr_all_organization_units ou
,xxdbd_oks_install_info_v dd
where aa.id = bb.dnz_chr_id
and bb.cle_id is null
and cc.cle_id = bb.id
and cc.dnz_chr_id = aa.id
and f1.user_id = bb.created_by
and f2.user_id = bb.last_updated_by
and cc.lse_id in (9,25,18,40)
and dd.line_id (+) = cc.id
and items.cle_id = cc.id
and cii.instance_id = items.object1_id1
and aa.authoring_org_id = ou.organization_id (+);
Here are the explain plans from TOAD:
Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
SELECT STATEMENT Optimizer Mode=CHOOSE 6 49124
NESTED LOOPS OUTER 6 80 K 49124
VIEW 6 80 K 49112
HASH JOIN 6 1 K 49112
HASH JOIN 17 K 2 M 20214
TABLE ACCESS FULL OKC.OKC_K_HEADERS_B 5 K 175 K 37
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 17 K 1 M 20162
INDEX SKIP SCAN XXDBD.XXDBD_OKC_K_LINES_B_N10 39 17085
TABLE ACCESS FULL OKC.OKC_K_LINES_B 502 K 34 M 27803
VIEW PUSHED PREDICATE 1 107 2
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 42 3 K 216
NESTED LOOPS 50 5 K 219
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_HEADERS_B 1 33 3
INDEX RANGE SCAN OKC.OKC_K_HEADERS_B_U2 1 2
INDEX RANGE SCAN OKC.OKC_K_LINES_B_N2 1 K 32
Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
SELECT STATEMENT Optimizer Mode=CHOOSE 245 63309
NESTED LOOPS 245 291 K 63309
NESTED LOOPS OUTER 245 286 K 63064
NESTED LOOPS 245 80 K 62574
HASH JOIN 245 74 K 61839
HASH JOIN 245 71 K 61756
HASH JOIN OUTER 245 68 K 61673
HASH JOIN 245 60 K 61664
HASH JOIN 205 K 32 M 28046
TABLE ACCESS FULL OKC.OKC_K_HEADERS_B 5 K 244 K 37
TABLE ACCESS FULL OKC.OKC_K_LINES_B 205 K 23 M 27803
TABLE ACCESS FULL OKC.OKC_K_LINES_B 2 M 168 M 27803
TABLE ACCESS FULL HR.HR_ALL_ORGANIZATION_UNITS 2 K 64 K 8
TABLE ACCESS FULL APPLSYS.FND_USER 13 K 172 K 81
TABLE ACCESS FULL APPLSYS.FND_USER 13 K 172 K 81
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
VIEW APPS.XXDBD_OKS_INSTALL_INFO_V 1 861 2
UNION-ALL PARTITION
NESTED LOOPS 1 167 9
NESTED LOOPS 1 108 8
NESTED LOOPS 1 85 7
NESTED LOOPS 1 51 6
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
TABLE ACCESS BY INDEX ROWID AR.HZ_PARTY_SITES 1 23 1
INDEX UNIQUE SCAN AR.HZ_PARTY_SITES_U1 1
TABLE ACCESS BY INDEX ROWID AR.HZ_LOCATIONS 1 59 1
INDEX UNIQUE SCAN AR.HZ_LOCATIONS_U1 1
NESTED LOOPS 1 144 8
NESTED LOOPS 1 85 7
NESTED LOOPS 1 51 6
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
TABLE ACCESS BY INDEX ROWID AR.HZ_LOCATIONS 1 59 1
INDEX UNIQUE SCAN AR.HZ_LOCATIONS_U1 1
NESTED LOOPS 1 161 8
NESTED LOOPS 1 85 7
NESTED LOOPS 1 51 6
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
TABLE ACCESS BY INDEX ROWID AR.HZ_PARTIES 1 76 1
INDEX UNIQUE SCAN AR.HZ_PARTIES_U1 1
TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 21 1
INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
And here is the SQL to join:
select * from xxdbd_contract_lines l, xxdbd_contract_flexfields f
where f.service_id (+) = l.service_id
and f.contract_number (+) = l.contract_number
and l.contract_number = 'NL0000014'
Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
SELECT STATEMENT Optimizer Mode=CHOOSE 1 49221
HASH JOIN OUTER 1 38 K 49221
VIEW APPS.XXDBD_CONTRACT_LINES 1 19 K 96
NESTED LOOPS OUTER 1 1 K 96
NESTED LOOPS 1 358 94
NESTED LOOPS 1 345 93
NESTED LOOPS 1 332 92
NESTED LOOPS 1 311 91
NESTED LOOPS 1 285 88
NESTED LOOPS 448 72 K 88
NESTED LOOPS OUTER 1 78 4
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_HEADERS_B 1 46 3
INDEX RANGE SCAN OKC.OKC_K_HEADERS_B_U2 1 2
TABLE ACCESS BY INDEX ROWID HR.HR_ALL_ORGANIZATION_UNITS 1 32 1
INDEX UNIQUE SCAN HR.HR_ORGANIZATION_UNITS_PK 1
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 378 32 K 84
INDEX RANGE SCAN XXDBD.XXDBD_OKC_K_LINES_B_N10 378 16
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 119
INDEX RANGE SCAN OKC.OKC_K_LINES_B_N2 1 K 32
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 21 1
INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
TABLE ACCESS BY INDEX ROWID APPLSYS.FND_USER 1 13 1
INDEX UNIQUE SCAN APPLSYS.FND_USER_U1 1
TABLE ACCESS BY INDEX ROWID APPLSYS.FND_USER 1 13 1
INDEX UNIQUE SCAN APPLSYS.FND_USER_U1 1
VIEW APPS.XXDBD_OKS_INSTALL_INFO_V 1 861 2
UNION-ALL PARTITION
NESTED LOOPS 1 167 9
NESTED LOOPS 1 108 8
NESTED LOOPS 1 85 7
NESTED LOOPS 1 51 6
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
TABLE ACCESS BY INDEX ROWID AR.HZ_PARTY_SITES 1 23 1
INDEX UNIQUE SCAN AR.HZ_PARTY_SITES_U1 1
TABLE ACCESS BY INDEX ROWID AR.HZ_LOCATIONS 1 59 1
INDEX UNIQUE SCAN AR.HZ_LOCATIONS_U1 1
NESTED LOOPS 1 144 8
NESTED LOOPS 1 85 7
NESTED LOOPS 1 51 6
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
TABLE ACCESS BY INDEX ROWID AR.HZ_LOCATIONS 1 59 1
INDEX UNIQUE SCAN AR.HZ_LOCATIONS_U1 1
NESTED LOOPS 1 161 8
NESTED LOOPS 1 85 7
NESTED LOOPS 1 51 6
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
TABLE ACCESS BY INDEX ROWID AR.HZ_PARTIES 1 76 1
INDEX UNIQUE SCAN AR.HZ_PARTIES_U1 1
VIEW APPS.XXDBD_CONTRACT_FLEXFIELDS 6 112 K 49124
NESTED LOOPS OUTER 6 80 K 49124
VIEW 6 80 K 49112
HASH JOIN 6 1 K 49112
HASH JOIN 17 K 2 M 20214
TABLE ACCESS FULL OKC.OKC_K_HEADERS_B 5 K 175 K 37
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 17 K 1 M 20162
INDEX SKIP SCAN XXDBD.XXDBD_OKC_K_LINES_B_N10 39 17085
TABLE ACCESS FULL OKC.OKC_K_LINES_B 502 K 34 M 27803
VIEW PUSHED PREDICATE 1 107 2
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 42 3 K 216
NESTED LOOPS 50 5 K 219
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_HEADERS_B 1 33 3
INDEX RANGE SCAN OKC.OKC_K_HEADERS_B_U2 1 2
INDEX RANGE SCAN OKC.OKC_K_LINES_B_N2 1 K 32
DECODE(l.attribute_category, 'Coverage Template Header', l.attribute3) Penalty_Bonus,
DECODE(l.attribute_category, 'Coverage Break', l.attribute1) Mon_Break_Start,
DECODE(l.attribute_category, 'Transaction Type', l.attribute1) Split_Covering,Uh oh, the dreaded entity attibute value, or generic, data model.
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:10678084117056
I am afraid slow performance is a built in feature of this database design, not much you can do in queries.
You could possibly create the views as materialized views and query those instead.
Quote from the linked article
But, how does it perform? Miserably, terribly, horribly. A simple "select
first_name, last_name from person" query is transformed into a 3-table join with
aggregates and all. Further, if the attributes are "NULLABLE" - that is, there
might not be a row in OBJECT_ATTRIBUTES for some attributes, you may have to
outer join instead of just joining which in some cases can remove more optimal
query plans from consideration.
Writing queries might look pretty straightforward, but it's impossible to do in
a performant fashion.
Compatible query for outer join..
SELECT e.ename, a.street_address, a.city,a.state,a.post_code
FROM emp e, addr a
WHERE e.empno = a.empno(+)
AND a.state = 'TEXAS'
Which is the compatible ANSI/ISO query for the above mentioned query (A or B)
A)
SELECT e.ename, a.street_address, a.city,a.state,a.post_code
FROM emp e RIGHT OUTER JOIN addr a
ON (e.empno = a.empno)
AND a.state = 'TEXAS'
B)
SELECT e.ename, a.street_address, a.city,a.state,a.post_code
FROM emp e LEFT OUTER JOIN addr a
ON (e.empno = a.empno)
AND a.state = 'TEXAS'
Thanks
Sameer
B)
SELECT e.ename, a.street_address, a.city,a.state,a.post_code
FROM emp e LEFT OUTER JOIN addr a
ON (e.empno = a.empno)
AND a.state = 'TEXAS'
http://www.oracle.com/oramag/oracle/01-nov/index.html?o61sql.html
You posted this question three times. Please post each question only once. Sometimes there is a delay from the time that you click on submit until the time that the post is displayed.
Maybe you are looking for
-
RFC GUID inconsistency detected
After creating a IACOR defination from ITS server side. A sm59 entry is then created on the R3 system. A test of the R3 sm59 tcp entry results in the following system message: When executing a Remote Function Call an internal error occurred.
-
Since installing Word 2010 (upgrading from Word 2003) there are no visable PDF Icons nor ability to create PDF Files using Adobe Acrobat 6.06. Operating system is Windows XP. Browser is IE8. Various attempts to bypass this situation have not been
-
I've been watching a video on my ipad... and the last 7 minutes are blank, just a black screen and no audio, yet on itunes it's there with all the audio and video, My question is, what happened?
-
Need documents for how to use OAM for APPS DBAs
Hi All, Need documents/pdfs, how to use OAM for APPS DBAs. Thanks a lot in advance
-
My iPad was purchased and registered in the USA. I am on a temporary assignment in Mexico. I purchased a iTunes gift card. When I tried to redeem it I get an error message. "Your iTuens store ([?]) does not match that of the gift certificate ([?])".