Can I rewrite this as semi join ?
Hi,
I hate queries like this:
select distinct t1.col1 from t1 , t2
where
t1.pk = t2.fk
I'm always trying to rewrite that as semi-join like
select t1.col1 from t1
where
t1.pk in (select t2.fk from t2);
but now I've got something like this:
SELECT DISTINCT prd.prd_id, prd.*
FROM prod1 prd,
prod1_parametry_kd prn,
prod1_param_k_dys pkd
WHERE prn.prn_prd_id = prd.prd_id
AND prn.prn_data_od <= SYSDATE
AND (prn.prn_data_do IS NULL OR prn.prn_data_do >= SYSDATE)
AND prn.prn_pkd_id = pkd.pkd_id
AND pkd.pkd_psl_lpr_id = :1
AND prd.prd_dostepnosc_od <= :2
AND (prd.prd_dostepnosc_do IS NULL OR prd.prd_dostepnosc_do >= TRUNC (:3)
I'm little confused because there is no connection between pkd and prd.
Is that query still rewritable as semi-join ?Regards.
Greg
Edited by: user10388717 on May 14, 2010 6:47 AM
Edited by: user10388717 on May 14, 2010 6:59 AM
Hi, Greg,
user10388717 wrote:
Hi,
I hate queries like this:
select distinct t1.col1 from t1 , t2
where
t1.pk = t2.fk
I'm always trying to rewrite that as semi-join like
select t1.col1 from t1
where
t1.pk in (select t2.fk from t2);
but now I've got something like this:
SELECT DISTINCT prd.prd_id, prd.*
FROM prod1 prd,
prod1_parametry_kd pkd,
prod1_param_k_dys pkd
WHERE prn.prn_prd_id = prd.prd_id
AND prn.prn_data_od <= SYSDATE
AND (prn.prn_data_do IS NULL OR prn.prn_data_do >= SYSDATE)
AND prn.prn_pkd_id = pkd.pkd_id
AND pkd.pkd_psl_lpr_id = :1
AND prd.prd_dostepnosc_od <= :2
AND (prd.prd_dostepnosc_do IS NULL OR prd.prd_dostepnosc_do >= TRUNC (:3)
I'm little confused because there is no connection between pkd and prd.
Is that query still rewritable as semi-join ?Regards.
Greg
Edited by: user10388717 on May 14, 2010 6:47 AMThere are two tables with the same alias, pkd. Should one of them be prn?
Anyway, sure, you can do what you want. The IN sub-query can be a join of two other tables, or perhaps there could be a nested IN sub-query.
Perhaps something like this:
SELECT DISTINCT prd.prd_id, prd.*
FROM prod1 prd,
WHERE prd_id IN ( SELECT prn.prn_prd_id
FROM prod1_parametry_kd prn,
prod1_param_k_dys pkd
WHERE prn.prn_data_od <= SYSDATE
AND ( prn.prn_data_do IS NULL
OR prn.prn_data_do >= SYSDATE
AND prn.prn_pkd_id = pkd.pkd_id
AND pkd.pkd_psl_lpr_id = :1
AND prd.prd_dostepnosc_od <= :2
AND (prd.prd_dostepnosc_do IS NULL OR prd.prd_dostepnosc_do >= TRUNC (:3)
;Of course, I can't test it.
Conditions that involve prd are in the main WHERE clause.
Conditions that involve the other tables, but not prd, are in the sub-query.
I suspect that doing a join would be at least as efficient. Why don't you want to do a join?
Edited by: Frank Kulash on May 14, 2010 10:08 AM
Similar Messages
-
How can I rewrite this update stmt to improve its poor performance?
Hi,
I have the following update stmt that runs for over 6 hours. Here is the SQL and its plan:
UPDATE TABLE1
SET mainveh = 'Y'
WHERE (comp#,polnum,a8dtef,a8deef,a8dtac,
DECODE(everif,'Y',10000,0)+auunit*100+vrcdsq)
IN (SELECT comp#,polnum,a8dtef,a8deef,a8dtac,
MAX(DECODE(everif,'Y',10000,0)+auunit*100+vrcdsq)
FROM TABLE1
GROUP BY comp#,polnum,a8dtef,a8deef,a8dtac);
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)|
| 0 | UPDATE STATEMENT | | 1 | 108 | | 798K (1)|
| 1 | UPDATE | TABLE1 | | | | |
| 2 | HASH JOIN | | 1 | 108 | 1079M| 798K (1)|
| 3 | TABLE ACCESS FULL | TABLE1 | 21M| 834M| | 224K (1)|
| 4 | VIEW | VW_NSO_1 | 21M| 1364M| | 440K (1)|
| 5 | SORT GROUP BY | | 21M| 794M| 2453M| 440K (1)|
| 6 | TABLE ACCESS FULL| TABLE1 | 21M| 794M| | 224K (1)|I'm using Oracle 10.2.0.3. The TABLE1 table has 21 million rows. The update stmt will update about 15 million rows. How can I rewrite this update stmt so it'll perform better? There is a primary index on all the columns selected in the subquery. That is the only index on TABLE1.
Thank you!
Edited by: user6053424 on Jul 21, 2010 6:59 AMHi,
Thank you for your suggestions. There is an index on the columns in the group by, it is the PK index on TABLE1. I'm suspecting that due to the amount of data to update, the optimizer decided that full table scan is cheaper than index scan. I'm very interested in the GTT idea, but still need some help if I decide to create a GTT from the subquery, because if I just do this:
create global temporary table table1_tmp
on commit preserve rows
as SELECT comp#,polnum,a8dtef,a8deef,a8dtac,
MAX(DECODE(everif,'Y',10000,0)+auunit*100+vrcdsq)
FROM TABLE1
GROUP BY comp#,polnum,a8dtef,a8deef,a8dtac;then the original update stmt still has the DECODE and such in it, I'm not sure how much benefit that'll do to us:
UPDATE TABLE1
SET mainveh = 'Y'
WHERE (comp#,polnum,a8dtef,a8deef,a8dtac,
DECODE(everif,'Y',10000,0)+auunit*100+vrcdsq)
IN (SELECT comp#,polnum,a8dtef,a8deef,a8dtac,???
FROM TABLE1);Your input is greatly appreciated! Thanks! -
How can i rewrite this code into java?
How can i rewrite this code into a java that has a return value?
this code is written in vb6
Private Function IsOdd(pintNumberIn) As Boolean
If (pintNumberIn Mod 2) = 0 Then
IsOdd = False
Else
IsOdd = True
End If
End Function
Private Sub cmdTryIt_Click()
Dim intNumIn As Integer
Dim blnNumIsOdd As Boolean
intNumIn = Val(InputBox("Enter a number:", "IsOdd Test"))
blnNumIsOdd = IsOdd(intNumIn)
If blnNumIsOdd Then
Print "The number that you entered is odd."
Else
Print "The number that you entered is not odd."
End If
End Sub873221 wrote:
I'm sorry I'am New to Java.Are you new to communication? You don't have to know anything at all about Java to know that "I have an error," doesn't say anything useful.
I'm just trying to get you to think about what your post actually says, and what others will take from it.
what does this error mean? what code should i replace and add? thanks for all response
C:\EvenOdd.java:31: isOdd(int) in EvenOdd cannot be applied to ()
isOdd()=true;
^
C:\EvenOdd.java:35: isOdd(int) in EvenOdd cannot be applied to ()
isOdd()=false;
^
2 errors
Telling you "what code to change it to" will not help you at all. You need to learn Java, read the error message, and think about what it says.
It's telling you exactly what is wrong. At line 31 of EvenOdd.java, you're calling isOdd(), with no arguments, but the isOdd() method requires an int argument. If you stop ant think about it, that should make perfect sense. How can you ask "is it odd?" without specifying what "it" is?
So what is this all about? Is this homework? You googled for even odd, found a solution in some other language, and now you're just trying to translate it to Java rather than actually learning Java well enough to simply write this trivial code yourself? -
i have tried to rewrite this code but keep getting errors. ive read loads of tutorials on actionperformed and mouseclicked i just need som1 to point me in the right direction
heres the code
public boolean mouseUp(Event e, int x, int y){
if (y == 0)
swit = true;
return true;
//else
if (pics[getMC(x,y)].getID() > rw*col/2){
return true;}
if (0 == track)
card1 = pics[getMC(x,y)];
start = new Date();
etime.start();
track = 2;
stat = "pic again";
repaint();
return true;
if (1 == track){
card1 = pics[getMC(x,y)];
track = 2;
stat = "pick again";
repaint();
return true;
else if (2 == track)
if (card1 == pics[getMC(x,y)]) return true;
card2 = pics[getMC(x,y)];
track = 3;
attempts++;
if (card1.getID() == card2.getID())
stat = "well done";
matched++;
if (rw*col/2 == matched)
stat = "finished";
etime = null;
else
stat = "Try Again";
repaint();
return true;
else
return false;
}Hi,
Do you want your code to listen to different Mouse events? and what other events?
ex:
copy the content of the below link and run the application
http://java.sun.com/docs/books/tutorial/uiswing/examples/events/MouseEventDemoProject/src/events/MouseEventDemo.java
http://java.sun.com/docs/books/tutorial/uiswing/examples/events/MouseEventDemoProject/src/events/BlankArea.java
If you have any problem with the code; please let us know
Regards,
Alan Mehio
London,UK -
How can we rewrite this query for better performance
Hi All,
The below query is taking more time to run. Any ideas how to improve the performance by rewriting the query using NOT EXITS or any other way...
Help Appreciated.
/* Formatted on 2012/04/25 18:00 (Formatter Plus v4.8.8) */
SELECT vendor_id
FROM po_vendors
WHERE end_date_active IS NULL
AND enabled_flag = 'Y'
and vendor_id NOT IN ( /* Formatted on 2012/04/25 18:25 (Formatter Plus v4.8.8) */
SELECT vendor_id
FROM po_headers_all
WHERE TO_DATE (creation_date) BETWEEN TO_DATE (SYSDATE - 365)
AND TO_DATE (SYSDATE))
ThanksTry this one :
This will help you for partial fetching of data
SELECT /*+ first_rows(50) no_cpu_costing */
vendor_id
FROM po_vendors
WHERE end_date_active IS NULL
AND enabled_flag = 'Y'
AND vendor_id NOT IN (
SELECT vendor_id
FROM po_headers_all
WHERE TO_DATE (creation_date) BETWEEN TO_DATE (SYSDATE - 365)
AND TO_DATE (SYSDATE))
overall your query is also fine, because, the in this query the subquery always contain less data compare to main query. -
Can we rewrite this query??
what i am i doing wrong here..
this query has performance issue.. RBE_SMF_ATTRIB_HISTORY table has 2 M records..
SELECT h.pricing_security_id,h.level1 mac1,
h.level3 mac3,h.level5 mac5,
h.mat_date maturity,h.country_of_issue country,h.px_date
FROM GPS.RBE_SMF_ATTRIB_HISTORY h
WHERE h.px_type = 'PS1'
AND (create_timestamp, pricing_security_id)
IN (SELECT MAX(smf.create_timestamp), smf.pricing_security_id
FROM GPS.RBE_SMF_ATTRIB_HISTORY smf,
GPS.WK_HOLDINGS_PORTFOLIO wkhp
WHERE smf.px_type = 'PS1'
AND smf.px_date = h.px_date
AND wkhp.pricing_security_id=smf.pricing_security_id
GROUP BY smf.pricing_security_id )SELECT h.pricing_security_id,h.level1 mac1,
h.level3 mac3,h.level5 mac5,
h.mat_date maturity,h.country_of_issue country,h.px_date
FROM GPS.RBE_SMF_ATTRIB_HISTORY h
WHERE h.px_type = 'PS1'
AND (create_timestamp, pricing_security_id, px_date) IN (SELECT MAX(smf.create_timestamp), smf.pricing_security_id, smf.px_date
FROM GPS.RBE_SMF_ATTRIB_HISTORY smf,
GPS.WK_HOLDINGS_PORTFOLIO wkhp
WHERE smf.px_type = 'PS1'
-- AND smf.px_date = h.px_date <-- try commenting out this line
AND wkhp.pricing_security_id = smf.pricing_security_id
GROUP BY smf.pricing_security_id, smf.px_date )
also do you have indexes on your pricing_security_id columns for table GPS.RBE_SMF_ATTRIB_HISTORY and GPS.WK_HOLDINGS_PORTFOLIO?
note: untested -
How can i rewrite this query so it uses less inner joins (it causes my temp space to explode :) )
( SELECT Waardes.*, Tellers.Nr_Dataitems, Tellers.Nr_Details FROM
( SELECT extractvalue(Value(el_node), 'Node/Id') node,
extractvalue(Value(el_dataitem), 'Detail/Title') Node_Title,
extractvalue(Value(el_dataitem), 'Detail/Value') Node_Value
FROM PHILIPS_XML x,
TABLE (xmlsequence (extract (value(x), '/Tree/Node'))) el_node,
TABLE (xmlsequence (extract (value(el_node),
'Node/DataItems/DataItem/DetailSet/Detail'))) el_dataitem
) Waardes
INNER JOIN
SELECT A.Node, A.Nr_Dataitems, B.Nr_details FROM
SELECT extractvalue(Value(el_node), 'Node/Id') node,
count(extract(Value(aaa), 'DataItem')) Nr_Dataitems
FROM PHILIPS_XML x,
TABLE (xmlsequence (extract (value(x), '/Tree/Node'))) el_node,
TABLE (xmlsequence (extract (value(el_node),
'Node/DataItems/DataItem'))) aaa
GROUP BY extractvalue(Value(el_node), 'Node/Id')
) A
INNER JOIN
SELECT extractvalue(Value(el_node), 'Node/Id') node,
count(extract(Value(bbb), 'Detail')) Nr_details
FROM PHILIPS_XML x,
TABLE (xmlsequence (extract (value(x), '/Tree/Node'))) el_node,
TABLE (xmlsequence (extract (value(el_node),
'Node/DataItems/DataItem'))) aaa,
TABLE (xmlsequence (extract (value(aaa),
'DataItem/DetailSet/Detail' ))) bbb
GROUP BY extractvalue(Value(el_node), 'Node/Id')
) B
on A.node = B.NODE
) Tellers
ON Waardes.NODE = Tellers.NODE )1st Make sure all paths are absolute (start with '/', not just the node name).
Which release are you using.. Is the document based on an XMLSchema, if so, what annotations were used when registered the XML Schema ?. What does the explain plan look like... -
Hi all,
Can we rewrite this query as simplest.Becasue when i Execute this query it will take more time appro 3hrs.So can we rewrite this as possible.
SELECT scon.uabscon_number,
scon.uabscon_cust_code,
scon.uabscon_prem_code,
scon.uabscon_mf_status,
letd.usrletd_mf_next_visit_date,
evau.ucrevau_invn_code,
evau.ucrevau_prod_number
FROM uimsmgr.usrletd letd,
uimsmgr.ucrevau evau,
uimsmgr.uabscon scon
WHERE scon.uabscon_mf_status = :cMoveForwardPhase
AND scon.uabscon_status_ind IN ('A','R')
AND evau.ucrevau_scon_number = scon.uabscon_number
AND evau.ucrevau_event_type = :currentLetterTypeLevel /* FLT1,ALT1,FLT2, ... */
AND evau.ucrevau_value_1 = :letterTypeCode /* FV1,ASV1, ... */
AND evau.ucrevau_activity_date = (SELECT max(ee.ucrevau_activity_date)
FROM uimsmgr.ucrevau ee
WHERE ee.ucrevau_scon_number = scon.uabscon_number
AND (ee.ucrevau_event_type like 'FLT%'
OR ee.ucrevau_event_type like 'ALT%'))
AND letd.usrletd_actual_cust_code = scon.uabscon_cust_code
AND letd.usrletd_prem_code = scon.uabscon_prem_code
AND letd.usrletd_letr_code = :letterTypeCode /* FV1,ASV1, ... */
AND letd.usrletd_printed_date <= SYSDATE - :mfFirstDelayDays
AND letd.usrletd_printed_ind = 'Y'
AND TRUNC(letd.usrletd_activity_date) >= TRUNC(evau.ucrevau_activity_date)
AND EXISTS ( SELECT 1
FROM uimsmgr.utvsrvc srvc,
uimsmgr.ucrserv serv
WHERE serv.ucrserv_scon_number = scon.uabscon_number
AND serv.ucrserv_cust_code = scon.uabscon_cust_code
AND serv.ucrserv_prem_code = scon.uabscon_prem_code
AND TRUNC(serv.ucrserv_next_visit_date) <= TRUNC(SYSDATE) + :mfDueRange
AND serv.ucrserv_srvc_code = srvc.utvsrvc_code
AND srvc.utvsrvc_bus_sector_id = 1 /* only business sector 1*/
AND DECODE( NVL(serv.ucrserv_next_visit_type, 'A'),
'NOFV', 'A',
'FV' , 'F',
'FAS' , 'A',
'A' , 'A',
'Z' ) = :visitType
);SELECT /*+ ordered */ scon.uabscon_number,
scon.uabscon_cust_code,
scon.uabscon_prem_code,
scon.uabscon_mf_status,
letd.usrletd_mf_next_visit_date,
evau.ucrevau_invn_code,
evau.ucrevau_prod_number
FROM uimsmgr.usrletd letd,
uimsmgr.ucrevau evau,
uimsmgr.uabscon scon
WHERE letd.usrletd_printed_date <= SYSDATE - :mfFirstDelayDays and scon.uabscon_mf_status = :cMoveForwardPhase
AND scon.uabscon_status_ind IN ('A','R')
AND evau.ucrevau_scon_number = scon.uabscon_number
AND evau.ucrevau_event_type = :currentLetterTypeLevel /* FLT1,ALT1,FLT2, ... */
AND evau.ucrevau_value_1 = :letterTypeCode /* FV1,ASV1, ... */
AND evau.ucrevau_activity_date = (SELECT max(ee.ucrevau_activity_date)
FROM uimsmgr.ucrevau ee
WHERE ee.ucrevau_scon_number = scon.uabscon_number
AND (ee.ucrevau_event_type like 'FLT%'
OR ee.ucrevau_event_type like 'ALT%'))
AND letd.usrletd_actual_cust_code = scon.uabscon_cust_code
AND letd.usrletd_prem_code = scon.uabscon_prem_code
AND letd.usrletd_letr_code = :letterTypeCode /* FV1,ASV1, ... */
AND letd.usrletd_printed_ind = 'Y'
AND TRUNC(letd.usrletd_activity_date) >= TRUNC(evau.ucrevau_activity_date)
AND EXISTS ( SELECT 1
FROM uimsmgr.utvsrvc srvc,
uimsmgr.ucrserv serv
WHERE serv.ucrserv_scon_number = scon.uabscon_number
AND serv.ucrserv_cust_code = scon.uabscon_cust_code
AND serv.ucrserv_prem_code = scon.uabscon_prem_code
AND TRUNC(serv.ucrserv_next_visit_date) <= TRUNC(SYSDATE) + :mfDueRange
AND serv.ucrserv_srvc_code = srvc.utvsrvc_code
AND srvc.utvsrvc_bus_sector_id = 1 /* only business sector 1*/
AND DECODE( NVL(serv.ucrserv_next_visit_type, 'A'),
'NOFV', 'A',
'FV' , 'F',
'FAS' , 'A',
'A' , 'A',
'Z' ) = :visitType
)I suggest this admitting on letd.usrletd_printed_date.
And it would be good if you would also have a lower limit for letd.usrletd_printed_date, so that you would have letd.usrletd_printed_date between ... -
ORA-02070 database does not support semi join in this context
The following merge sql on Oracle 11g throws "ORA-02070 database does not support semi join in this context".
MERGE INTO ORDERS tgt
USING
SELECT C.short_name, C.customer_id
FROM customers C
WHERE customer_id IN ( SELECT distinct customer id FROM orders O WHERE O.order_date > SYSDATE - 3 )
)src
ON ( tgt.customer_id=src.customer_id )
WHEN MATCHED THEN
UPDATE SET tgt.short_name=src.short_name;
Any ideas? This piece of code was working on an earlier version of Oracle 11g.
Thanks,
AnuHi, Anu,
You can try this:
MERGE INTO ORDERS tgt
USING
SELECT C.short_name, C.customer_id
FROM customers C
) src
ON ( tgt.customer_id = src.customer_id
AND tgt.order_date > SYSDATE - 3
WHEN MATCHED THEN
UPDATE SET tgt.short_name = src.short_name; It's surprising that the error message mentioned a semi-join, because you weren't doing a semi-join. An example of a semi-join is:
MERGE INTO ORDERS tgt
USING
SELECT DISTINCT
C.short_name, C.customer_id
FROM customers C
JOIN orders o ON c.customer_id = o.customer_id
WHERE o.order_date > SYSDATE - 3
) src
ON (tgt.customer_id = src.customer_id)
WHEN MATCHED THEN
UPDATE SET tgt.short_name = src.short_name; but perhaps the optimizer re-wrote your IN sub-query as a semi-join.
An EXISTS sub-query is another way to get the results you want, unless it causes ORA-02070, also. Natrually, I can't test anythihng, since you didn't post any sample data.
Edited by: Frank Kulash on Apr 5, 2011 11:34 AM -
Can I do this using the Time Capsule. I am not tech, so bear with me. Can I get the iPad to connect wirelessly to the TC, which connects wirelessly to the Canon MP495? Or, can I connect/network the iPad to the iMac to print?
Either way, or if there is any other solution, I would appreciate if someone would walk me through it, or point me to a plain-speaking resource.
Thankyou.
Actually, one more: I would like to connect my HP laptop as well. I have heard this is not simple, but possible.You can create a wifi network with your TC, and you can join this network with your iPad. However, your printer does not support the AirPrint protocol, so you will not be able to print from your iPad, unless you load additional software.
These are the steps:
1. (You may have completed this step already) Set up your TC to create a wireless network. You can do this from AirPort Utility on your Mac or from the AirPort Utility App on your iPad (free download from the App Store).
2. From your iPad, go to settings / wifi and join the network.
3. Download the Canon iPhone App from the App store on your iPad
4. You can now print photos from your iPad to your Canon printer.
If you want full functionality, (not just photos), there is software for your Mac that makes your printer available to your iPad through AirPrint (Printopia). The downside is, you have to purchase it, and you have to have your Mac running when you want to print from your iPad.
Good luck! -
How can I perform this kind of range join query using DPL?
How can I perform this kind of range join query using DPL?
SELECT * from t where 1<=t.a<=2 and 3<=t.b<=5
In this pdf : http://www.oracle.com/technology/products/berkeley-db/pdf/performing%20queries%20in%20oracle%20berkeley%20db%20java%20edition.pdf,
It shows how to perform "Two equality-conditions query on a single primary database" just like SELECT * FROM tab WHERE col1 = A AND col2 = B using entity join class, but it does not give a solution about the range join query.I'm sorry, I think I've misled you. I suggested that you perform two queries and then take the intersection of the results. You could do this, but the solution to your query is much simpler. I'll correct my previous message.
Your query is very simple to implement. You should perform the first part of query to get a cursor on the index for 'a' for the "1<=t.a<=2" part. Then simply iterate over that cursor, and process the entities where the "3<=t.b<=5" expression is true. You don't need a second index (on 'b') or another cursor.
This is called "filtering" because you're iterating through entities that you obtain from one index, and selecting some entities for processing and discarding others. The white paper you mentioned has an example of filtering in combination with the use of an index.
An alternative is to reverse the procedure above: use the index for 'b' to get a cursor for the "3<=t.b<=5" part of the query, then iterate and filter the results based on the "1<=t.a<=2" expression.
If you're concerned about efficiency, you can choose the index (i.e., choose which of these two alternatives to implement) based on which part of the query you believe will return the smallest number of results. The less entities read, the faster the query.
Contrary to what I said earlier, taking the intersection of two queries that are ANDed doesn't make sense -- filtering is the better solution. However, taking the union of two queries does make sense, when the queries are ORed. Sorry for the confusion.
--mark -
After update to be iOS 6.0.1, Wi-Fi is not connected automatically. I have to reconnect or join my known network manually all the time. How can I solve this problem? It is so tedious.
Same here... on my girlfriend's iPod touch (4th gen).
It's very annoying... really! -
Hi, I am trying to download IOS7 (not sure if it's 1 or 2) to my ipad. The programme has locked at the 'Choose a Wif-Fi network' page, a box says 'joining other network' but the page is greyed out and can't move from it. How can I clear this screen and finish the download. Thanks
Hello Den53,
Thanks for using Apple Support Communities.
For more information on this, take a look at:
iOS: Turning off and on (restarting) and resetting
http://support.apple.com/kb/HT1430?viewlocale=en_US
Press and hold the Sleep/Wake button for a few seconds until the red "slide to power off" slider appears, and then slide the slider.
After the device has turned off, press and hold the Sleep/Wake button until the Apple logo appears.
Best of luck,
Mario -
How can I make this join in ADF and make CRUD operation in this
How to make this relation in ADF
I have table employees and this is my master table
Table Name: Employees
Columns:
Employee_id(PK)
Employee_name
Employee_Salary
I have a child table that is called related employee that contains employees related to this employee
Table_name: Related_Employee
Columns:
Related_Employee_Table_Id(PK)
Employee_id(FK)
Related_Employee_Id
When I open employee id = 100 for example and add related employee id = 10
this is added with no problem but the requirement is that when I open employee 10 I find employee id 100 as related employee
How can I make this scenario.The best way to understand this is to look at an example. If you are using an oracle database such as XE for you have a schema called hr. This shema has a number of tables two of which are departments and employees. a department has multiple employees correct. So in your example a employee may be related to x # of other employees perhaps. A very similar scenario as that in the hr Schema. If you don't have an Oracle XE database, download one from here -> http://www.oracle.com/technetwork/database/express-edition/downloads/index.html
Create Business Components off of the Departments and Employees schema and you'll see that due to the db design, you get what you're talking about for free (i.e. the join). Thus, you have the master-detail relationship you're looking for. For a quick tip, here is the relationship between departments and employees in the hr schema via a create script that you can exam with data inserts included:
SET SQLBLANKLINES ON
CREATE TABLE DEPARTMENTS
DEPARTMENT_ID NUMBER(4, 0) NOT NULL
, DEPARTMENT_NAME VARCHAR2(30 BYTE) NOT NULL
, MANAGER_ID NUMBER(6, 0)
, LOCATION_ID NUMBER(4, 0)
, CONSTRAINT DEPT_ID_PK PRIMARY KEY
DEPARTMENT_ID
USING INDEX
CREATE UNIQUE INDEX DEPT_ID_PK ON DEPARTMENTS (DEPARTMENT_ID ASC)
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
ENABLE
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 1
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
CREATE TABLE EMPLOYEES
EMPLOYEE_ID NUMBER(6, 0) NOT NULL
, FIRST_NAME VARCHAR2(20 BYTE)
, LAST_NAME VARCHAR2(25 BYTE) NOT NULL
, EMAIL VARCHAR2(25 BYTE) NOT NULL
, PHONE_NUMBER VARCHAR2(20 BYTE)
, HIRE_DATE DATE NOT NULL
, JOB_ID VARCHAR2(10 BYTE) NOT NULL
, SALARY NUMBER(8, 2)
, COMMISSION_PCT NUMBER(2, 2)
, MANAGER_ID NUMBER(6, 0)
, DEPARTMENT_ID NUMBER(4, 0)
, CONSTRAINT EMP_EMP_ID_PK PRIMARY KEY
EMPLOYEE_ID
USING INDEX
CREATE UNIQUE INDEX EMP_EMP_ID_PK ON EMPLOYEES (EMPLOYEE_ID ASC)
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
ENABLE
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 1
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
CREATE INDEX DEPT_LOCATION_IX ON DEPARTMENTS (LOCATION_ID ASC)
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
CREATE INDEX EMP_DEPARTMENT_IX ON EMPLOYEES (DEPARTMENT_ID ASC)
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
CREATE INDEX EMP_JOB_IX ON EMPLOYEES (JOB_ID ASC)
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
CREATE INDEX EMP_MANAGER_IX ON EMPLOYEES (MANAGER_ID ASC)
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
CREATE INDEX EMP_NAME_IX ON EMPLOYEES (LAST_NAME ASC, FIRST_NAME ASC)
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_EMAIL_UK UNIQUE
EMAIL
USING INDEX
CREATE UNIQUE INDEX EMP_EMAIL_UK ON EMPLOYEES (EMAIL ASC)
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
ENABLE;
ALTER TABLE DEPARTMENTS
ADD CONSTRAINT DEPT_LOC_FK FOREIGN KEY
LOCATION_ID
REFERENCES LOCATIONS
LOCATION_ID
ENABLE;
ALTER TABLE DEPARTMENTS
ADD CONSTRAINT DEPT_MGR_FK FOREIGN KEY
MANAGER_ID
REFERENCES EMPLOYEES
EMPLOYEE_ID
ENABLE;
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_DEPT_FK FOREIGN KEY
DEPARTMENT_ID
REFERENCES DEPARTMENTS
DEPARTMENT_ID
ENABLE;
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_JOB_FK FOREIGN KEY
JOB_ID
REFERENCES JOBS
JOB_ID
ENABLE;
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_MANAGER_FK FOREIGN KEY
MANAGER_ID
REFERENCES EMPLOYEES
EMPLOYEE_ID
ENABLE;
ALTER TABLE DEPARTMENTS
ADD CONSTRAINT DEPT_NAME_NN CHECK
(DEPARTMENT_NAME IS NOT NULL)
ENABLE;
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_EMAIL_NN CHECK
(EMAIL IS NOT NULL)
ENABLE;
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_HIRE_DATE_NN CHECK
(HIRE_DATE IS NOT NULL)
ENABLE;
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_JOB_NN CHECK
(JOB_ID IS NOT NULL)
ENABLE;
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_LAST_NAME_NN CHECK
(LAST_NAME IS NOT NULL)
ENABLE;
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_SALARY_MIN CHECK
(SALARY > 0)
ENABLE;
COMMENT ON TABLE DEPARTMENTS IS 'Departments table that shows details of departments where employees
work. Contains 27 rows; references with locations, employees, and job_history tables.';
COMMENT ON TABLE EMPLOYEES IS 'employees table. Contains 107 rows. References with departments,
jobs, job_history tables. Contains a self reference.';
COMMENT ON COLUMN DEPARTMENTS.DEPARTMENT_ID IS 'Primary key column of departments table.';
COMMENT ON COLUMN DEPARTMENTS.DEPARTMENT_NAME IS 'A not null column that shows name of a department. Administration,
Marketing, Purchasing, Human Resources, Shipping, IT, Executive, Public
Relations, Sales, Finance, and Accounting. ';
COMMENT ON COLUMN DEPARTMENTS.MANAGER_ID IS 'Manager_id of a department. Foreign key to employee_id column of employees table. The manager_id column of the employee table references this column.';
COMMENT ON COLUMN DEPARTMENTS.LOCATION_ID IS 'Location id where a department is located. Foreign key to location_id column of locations table.';
COMMENT ON COLUMN EMPLOYEES.EMPLOYEE_ID IS 'Primary key of employees table.';
COMMENT ON COLUMN EMPLOYEES.FIRST_NAME IS 'First name of the employee. A not null column.';
COMMENT ON COLUMN EMPLOYEES.LAST_NAME IS 'Last name of the employee. A not null column.';
COMMENT ON COLUMN EMPLOYEES.EMAIL IS 'Email id of the employee';
COMMENT ON COLUMN EMPLOYEES.PHONE_NUMBER IS 'Phone number of the employee; includes country code and area code';
COMMENT ON COLUMN EMPLOYEES.HIRE_DATE IS 'Date when the employee started on this job. A not null column.';
COMMENT ON COLUMN EMPLOYEES.JOB_ID IS 'Current job of the employee; foreign key to job_id column of the
jobs table. A not null column.';
COMMENT ON COLUMN EMPLOYEES.SALARY IS 'Monthly salary of the employee. Must be greater
than zero (enforced by constraint emp_salary_min)';
COMMENT ON COLUMN EMPLOYEES.COMMISSION_PCT IS 'Commission percentage of the employee; Only employees in sales
department elgible for commission percentage';
COMMENT ON COLUMN EMPLOYEES.MANAGER_ID IS 'Manager id of the employee; has same domain as manager_id in
departments table. Foreign key to employee_id column of employees table.
(useful for reflexive joins and CONNECT BY query)';
COMMENT ON COLUMN EMPLOYEES.DEPARTMENT_ID IS 'Department id where employee works; foreign key to department_id
column of the departments table'; -
the option Join CD Tracks under Advanced tab is now greyed out and unavailalbe from downloading audio CDs. How can I fix this?
This post is closed. No replies needed
Maybe you are looking for
-
Sync metadata to multiple files - how does that work?
Frustrating. In Library Module of LR4.4 under Vista 32, I have corrected a "Capture Time" of a single jpg Photo via the "Edit Capture Time" dialog. The new date correctly shows up in the "Date Time Original" EXIF field of the Metadata panel on the
-
Dbms_sql.parse: varchar2a version does NOT throw ORA-24344
I'm trying to execute some generated code in 10.2. using the varchar2a version of dbms_sql.parse. This works fine, but when the there is something wrong in the generated code, I do not get an exception (I do get it with the varchar2 version). So when
-
Hi following is my coding the scenario is like....i have created one form which contain 'SUBMIT' button when i will click that submit pushbutton...email should go to specific mail id i have called function module. 'so_new_document_att_api1' follow
-
Hi, we need your urgent help regarding mac os x server 10.6 installation, actually we are stuck in the installation at the point of Network settings. getting an error " Please inspect your network setting and try again" pls give us a solution of it ,
-
MBP Goes Into Sleep Mode w/o permission.
I am trying to download a larger file and I leave my computer for a few hours only to come back to the MBP in sleep mode and has shut down all the programs I was running. I set the energy saver preferences to never fall to sleep when its inactive how