Merge.. When Matched... Query... please help...!!
Hello Friends - With following details, can some one help me in writing a MERGE query, when Matched update ArtsDate and when not Matched Insert new rwo in CE Table.
PT: Parameter Table
MSO
1
2
5
6
FO Table
MSO EngModel
1 RM713
2 TT344
3 TT189
4 TT349
5 RM735
6 TT119
7 RM734
8 RM710
SCH Table
MsO SchDate SchSlot
1 10/18/2012 1
2 3/16/2012 4
3 12/13/2011 7
4 12/14/2011 4
5 12/15/2011 2
6 12/19/2011 5
7 12/20/2011 8
8 12/5/2011 3
SD SafetyDays
EngModel SDays
RM710 4
RM713 9
RM734 4
RM735 4
TT344 7
TT119 8
TT189 16
TT349 16
CE: Table that needs to be updated
MSO ARTSDate SchDate SchSlot
2 9/30/2012 3/16/2012 4
4 4/26/2012 12/14/2011 4
5 10/15/2012 12/15/2011 2
7 2/2/2012 12/20/2011 8
CE: Result (updated Table) Remarks
MSO ARTSDate SCHdaTE SchSlot
2 3/23/2012 3/16/2012 4 matched
4 12/30/2011 12/14/2011 4
5 12/19/2011 12/15/2011 2 matched
7 12/24/2011 12/20/2011 8
1 10/27/2012 10/18/2012 1 not matched
6 12/27/2011 12/19/2011 5 not matched
Notes on updated CE Table in above table:
Match PT.MSO with CE.MSO
When matched (e.g. MSO# 2 & 5), Update ARTS per following:
1. Take SchDate for same MSO from SCH table
2. Add SD.Sdays from SafetyDays table that refers to same EngModel present in FO Table for the same MSO in SCH table
When not matched (e.g. MSO# 1 & 6), Insert new row into CE Table
VALUES:
SCH.MSO
ARTS (use same same formula as above)
SCH.SCH
SCH.SchSlot
Thanks for your help..
Sunil
Edited by: 865144 on Jun 10, 2011 12:38 PM
Edited by: 865144 on Jun 10, 2011 12:49 PM
Thanks a ton Ganesh for your help. This is what I created from the code (after needed modifications) you have given to me:
MERGE INTO cmopsexport tgt
USING (SELECT RA.factoryorderid, '030' recordcode, FO.ud_order_prty_code,
SCH.productionsequence, FO.frozen, FO.ud_orig_seq_schd_date,
SCH.productiondate, FO.ud_eng_mdl_no,
TO_CHAR (add_work_days(FO.resourceid, SCH.productiondate,
(Select SafetyDays from UD_SafetyDays
where ud_safetydays.effdate = (select max(SD.effdate) from UD_SafetyDays SD
where SD.effdate <= FO.ud_order_rcvng_date
AND TRIM(SD.EngModel) = TRIM(FO.ud_eng_mdl_no)
and TRIM(FO.ud_eng_mdl_no) = trim(UD_SafetyDays.EngModel)
'YYYYMMDD'
) ud_calculated_arts,
FO.ud_lane
FROM ud_recalc_arts RA,
schedule SCH,
factoryorder FO
WHERE RA.factoryorderid = SCH.factoryorderid
AND SCH.factoryorderid = FO.factoryorderid
) src
ON (tgt.factoryorderid = src.factoryorderid)
WHEN MATCHED THEN
UPDATE
SET
tgt.recordcode = src.recordcode,
tgt.ud_order_prty_code = src.ud_order_prty_code,
tgt.productionsequence = src.productionsequence,
tgt.frozen = src.frozen,
tgt.ud_orig_seq_schd_date = src.ud_orig_seq_schd_date,
tgt.productiondate = src.productiondate,
tgt.ud_eng_mdl_no = src.ud_eng_mdl_no,
tgt.ud_calculated_arts = src.ud_calculated_arts,
tgt.ud_lane = src.ud_lane
WHEN NOT MATCHED THEN
INSERT
VALUES (src.factoryorderid, src.recordcode, src.ud_order_prty_code,
src.productionsequence, src.frozen, src.ud_orig_seq_schd_date,
src.productiondate, src.ud_eng_mdl_no, src.ud_calculated_arts,
src.ud_lane);
And the above works too!!
Thank you once again...
Sunil
Similar Messages
-
I am working on big project and in accidentally flatten the file and i saved it as PSD in then I exited Photoshop. the next time when i open the file it is merged on one page. please help!
Flattening and merging are very similar. The main difference is merging keeps the transparent areas, whereas flattening removes all transparent areas by giving it a white background. A good example of flattening is a jpg image.
Since you have closed the file by closing photoshop, that means that the history is now gone, no way of undoing.
So that leaves you with two choices.
You can either recreate the whole document.
Or you can make selections of areas you are keeping and moving them one at a time to new layers. Keep each object on a separate layer. Then redo the area behind those objects. -
I have 2 users on my Mac I want to merge the photo libraries please help!
I have 2 users on my Mac I want to merge the photo libraries please help!
What version of iPhoto? Do yuo hae Aperature 3.3? With iPhoto 9.3 and Aperature 3.3 you can merge iPhoto libraries - you also can do it with the paid version of iPhoto Library Manager - http://www.fatcatsoftware.com/iplm/ -
LN -
How to improve the performance of the attached query, Please help
Hi,
How to improve performance of the below query, Please help. also attached explain plan -
SELECT Camp.Id,
rCam.AccountKey,
Camp.Id,
CamBilling.Cpm,
CamBilling.Cpc,
CamBilling.FlatRate,
Camp.CampaignKey,
Camp.AccountKey,
CamBilling.billoncontractedamount,
(SUM(rCam.Impressions) * 0.001 + SUM(rCam.Clickthrus)) AS GR,
rCam.AccountKey as AccountKey
FROM Campaign Camp, rCamSit rCam, CamBilling, Site xSite
WHERE Camp.AccountKey = rCam.AccountKey
AND Camp.AvCampaignKey = rCam.AvCampaignKey
AND Camp.AccountKey = CamBilling.AccountKey
AND Camp.CampaignKey = CamBilling.CampaignKey
AND rCam.AccountKey = xSite.AccountKey
AND rCam.AvSiteKey = xSite.AvSiteKey
AND rCam.RmWhen BETWEEN to_date('01-01-2009', 'DD-MM-YYYY') and
to_date('01-01-2011', 'DD-MM-YYYY')
GROUP By rCam.AccountKey,
Camp.Id,
CamBilling.Cpm,
CamBilling.Cpc,
CamBilling.FlatRate,
Camp.CampaignKey,
Camp.AccountKey,
CamBilling.billoncontractedamount
Explain Plan :-
Description Object_owner Object_name Cost Cardinality Bytes
SELECT STATEMENT, GOAL = ALL_ROWS 14 1 13
SORT AGGREGATE 1 13
VIEW GEMINI_REPORTING 14 1 13
HASH GROUP BY 14 1 103
NESTED LOOPS 13 1 103
HASH JOIN 12 1 85
TABLE ACCESS BY INDEX ROWID GEMINI_REPORTING RCAMSIT 2 4 100
NESTED LOOPS 9 5 325
HASH JOIN 7 1 40
SORT UNIQUE 2 1 18
TABLE ACCESS BY INDEX ROWID GEMINI_PRIMARY SITE 2 1 18
INDEX RANGE SCAN GEMINI_PRIMARY SITE_I0 1 1
TABLE ACCESS FULL GEMINI_PRIMARY SITE 3 27 594
INDEX RANGE SCAN GEMINI_REPORTING RCAMSIT_I 1 1 5
TABLE ACCESS FULL GEMINI_PRIMARY CAMPAIGN 3 127 2540
TABLE ACCESS BY INDEX ROWID GEMINI_PRIMARY CAMBILLING 1 1 18
INDEX UNIQUE SCAN GEMINI_PRIMARY CAMBILLING_U1 0 1Hello,
This has really nothing to do with the Oracle Forms product.
Please, send the SQL or/and PL/SQL questions in the corresponding forums.
Francois -
Hi i recieved an ipod touch gen 5 for christmas and it worked perfectly on the 30th it decided to instantly shut down on me and over heat iv tried all of apples recommeded techniques but it wont work at all even when charging someone please help me!
Try:
- iOS: Not responding or does not turn on
- Also try DFU mode after try recovery mode
How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
- If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
- If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
Apple Retail Store - Genius Bar -
Approval process QUERY - Please help guys....
Hello Experts,
I have found some threads in this subject but non of them seem to work for me.
My need is :
when my employee tries to turn an order into an Invoice witch its card is set to groupname of 'over seas clients' the invoice will not be produced and the approval pop up will show.
this is what i tryed :
SELECT distinct 'true' FROM OINV T0 INNER JOIN OCRD T1 ON T0.CardCode = T1.CardCode INNER JOIN OCRG T2 ON T1.GroupCode = T2.GroupCode AND T2.GroupName 'Over seas clients' where T0.CardCode = $[$4.0.0]
nothing happens and the approval pop up never shows up.
Could someone Please help me with this query?
Thanks alot
D.medI thin approval process work like in this manner.
when you add any SO for particular condition matches then approval pop up will come, and then that SO gone to Approval. After approval user can able to make Invoice.
Hence i think in your case you need to made a query in SO that when the particular groupname is added then aproval should pop up.
Else you can kept the approval process in AR Invoice that if particular groupname is added then pop up.
For Approval process you need to select this query in Approval Template. -
Ipod error message when connected. Please help
Windows XP
I have had my 30 gigabyte ipod for almost a year and i've never had any problems with it before. But recently our area wasn't able to get broadband. So i was unable to download the recent ipod and itunes updates. I have done that now.. but i think something has affected my ipod. When i plug it into my computer nothing comes up on my ipod screen and i can continue browsing music etc.. i know this isn't supposed to happen. And on my computer an error message comes up saying "USB device not recognized. One of the USB devices attached to this computer has malfunctioned, and Windows does not recognise it. "
Please help me!Okay. So i'll tell you the steps i have taken. I've uninstalled all the ipod updaters i had on my computer, eg 2006 and 2005.. and i reinstalled the latest version of itunes. I also went to device manager and all that but it only came up in the list at "unknown device" and i uninstalled the driver and tried to reinstall it but it came up saying it was an unknown device again. I tried right clicking on it and going "scan for hardware updates" but it told me the one i have installed is the nearest match. I also tried connecting my ipod to my computer in disc mode which did nothing. But i have discovered my ipod charges when i plug it in.. but the computer freezes on the black dos screen (as it always has for me when i turn the computer on with the ipod plugged in) and the ipod remains charging. but it seems if i plug it in after windows has loaded it's not even recognised.
I'm sorry for making it so long but i really really need help -
MERGE - WHEN MATCHED (for a table with 2 column that are the keys)
Hi
I am using merge to insert/update a table whenever new records come in.
My question is if the table has 2 columns and both are a part of the primary key, do I need to have the merge statement "when matched" as well? Since both the columns are part of the key, when matched wont make sense here. I will only need when not matched, then insert.
Please correct if I am wrong.
Thx!You need to be matchning/not matching on the whole primary key. Matched and not matched are required before 10G.
MERGE INTO table1 loctab
USING (SELECT colpk1,
colpk2,
col3,
col4
FROM table2) remtab
ON (loctab.colpk1 = remtab.colpk1 AND loctab.colpk2 = remtab.colpk2)
WHEN MATCHED
THEN
UPDATE SET loctab.col3 = remtab.col3,
loctab.col4 = remtab.col4
WHEN NOT MATCHED
THEN
INSERT (loctab.colpk1,
loctab.colpk2,
loctab.col3,
loctab.col4
VALUES (remtab.colpk1,
remtab.colpk2,
remtab.col3,
remtab.col4
); -
How to rewrite this query without sub query please help me
Hello All Good Evening,
Could you please help me with this query, how can i write this query without sub query, or how can write this query another ways
please help me
select planno, status1, count(*) Counts from
select a.ValetNO PlanNo ,
case
when JoinCode in ('00', '01', '02') then 'Actcess'
when JoinCode in ('20', '21', '22', '23','38', '39') then
'Secured' else 'Other' end Status1 ---, COUNT (*)
from dbo.ppt a(NOLOCK) left join dbo.acts b on a.P_ID = b.P_ID and a.ValetNO = b.ValetNO
--group by a.ValetNO
a group by planno, status1
order by 2
Thank you in Advance
MilanWhats your objective here? Sorry, am not able to understand the reason for this change.
Try the below:(Not tested)
;With cte
As
select a.ValetNO PlanNo ,
case
when JoinCode in ('00', '01', '02') then 'Actcess'
when JoinCode in ('20', '21', '22', '23','38', '39') then
'Secured' else 'Other' end Status1 ---, COUNT (*)
from dbo.ppt a(NOLOCK) left join dbo.acts b on a.P_ID = b.P_ID and a.ValetNO = b.ValetNO
select planno, status1, count(*) Counts from cte
a group by planno, status1
order by 2
Even below:
select a.ValetNO PlanNo ,
case
when JoinCode in ('00', '01', '02') then 'Actcess'
when JoinCode in ('20', '21', '22', '23','38', '39') then
'Secured' else 'Other' end Status1 , COUNT (1)
from dbo.ppt a(NOLOCK) left join dbo.acts b on a.P_ID = b.P_ID and a.ValetNO = b.ValetNO
Group by a.ValetNO ,
case
when JoinCode in ('00', '01', '02') then 'Actcess'
when JoinCode in ('20', '21', '22', '23','38', '39') then
'Secured' else 'Other' end -
Passing parameter to a SQL query - Please help
Hi All,
I am new to JDBC. I have been trying to pass an external variable to an SQL Query.
The query is
String username1="le";
PreparedStatement pstmt = null;
pstmt = c.prepareStatement("select * from users where USER_NAME like '%?%'");
pstmt.setString(1, username1);
pstmt.executeQuery();
ResultSet rs = pstmt.getResultSet();
I am trying to retrieve values from the users table where the USER_NAME column value that is a String contains the supplied value username1.
I am using the question mark (?) character to pass the value from the variable username1. I am also using the '%' substitution character which matches for any number of characters. So, the above query should retrieve rows where the USER_NAME is something like "charles","leander","Elena" etc.( that contains "le")
I am getting the error:
SQLException: java.sql.SQLException: ORA-01006: bind variable does not exist
I changed the query to
PreparedStatement pstmt = null;
pstmt = c.prepareStatement("select * from users where USER_NAME like '% " + username1 + "%'");
//pstmt.setString(1, username1);
pstmt.executeQuery();
This time , it is not giving the error and retrieving properly.
But I want to use the original query and use the "pstmt.setString(1, username1); " . Is there any way of achieving this?
Please help.
Cheers,
charles_amhi,
try this...
String username1="%le%";
pstmt = c.prepareStatement("select * from users where USER_NAME like ?")
pstmt.setString(1,username1);
cheers,
rpk -
I have started using multi-cam and notice that almost always when using multi-cam the rendered results are incorrect - with many camera selections forgotten or flipped to exact opposite!
Very frustrating - especially since you discover after render!!
Many times when I select Camera A at some point and then later go to beginning of sequence - many of the selections have been reversed with reversal again at clip transitions - resulting in exact opposite of what I selected or random changes. Locking the tracks does not prevent this. It seems to be overriding my choices based on some program logic!!
This is with latest Premiere Pro 2014.1 {8.1 build)
Useless feature if you cannot get it to render your selections but rather random selection
Wish there was a manual! And not just incomplete video tutorials that are teaser for some associate's paid training (of unknown value).
Or at least quick forum / support response from Adobe representatives so I can be productive with the tooling.
Another week of no answers and I will have to recreate in FCP X where multi cam seems to work fine.
Not the best for brand loyalty, eh?
Please helpI'm thinking it might be operator error on this one. Here's a process that works every time.
1. Create a sequence matching the specs of your footage.
2. Add your clips.
3. Sync manually.
4. Create a second sequence matching the first.
5. Nest the first sequence into the second.
6. Right click on that nested sequence and choose Multi-Camera>Enable
7. Turn on the Multi-camera view in the Program Monitor.
8. Play the sequence in real time, switch angles using keyboard shortcuts. If you make a mistake, leave it for later.
9. When you're done with the first pass in real time, go back to the normal view in the Program Monitor.
10. Move through the sequence a second time, cut by cut, tweaking as necessary with the Rolling Edit tool (shortcut N).
On a side note, 2014.2 is actually the current version. You should update. -
Hello Forum Members,
Can you please help me out:
SQL> select * from quarter_test4;
QUARTER CONFIG REP_DATE
Q1-2007 10 12-JAN-07
Q2-2007 10 21-APR-07
Q3-2007 870 14-AUG-07
Q4-2007 50 15-NOV-07
Q1-2008 60 02-JAN-09
Q4-2006 160 02-DEC-06
I want the following out put:
Please note that the future quarters should have current quarter sum(config).Please note that The current table
does not hold future quarters.I have to genarate query on which a report is based.
My Query:
SELECT quarter,
CASE
WHEN qtr > TRUNC(SYSDATE, 'q')
THEN LAST_VALUE(sum_config IGNORE NULLS) OVER(ORDER BY qtr)
ELSE sum_config
END sum_config
FROM (SELECT qtr, q.qtrstr quarter, SUM(qt.config) sum_config
FROM (SELECT 'Q' || TO_CHAR(qtr, 'q-yyyy') qtrstr, qtr
FROM (SELECT ADD_MONTHS(ADD_MONTHS(TRUNC(SYSDATE, 'q'), -13), 3 *(LEVEL - 1)) qtr
FROM DUAL
CONNECT BY LEVEL <= 9)
ORDER BY qtr) q,
quarter_test4 qt
WHERE qt.quarter(+) = q.qtrstr
GROUP BY qtr, q.qtrstr)
ORDER BY qtr;
Correct Output Generated:
QUARTER SUM_CONFIG
Q4-2006 160
Q1-2007 10
Q2-2007 10
Q3-2007 870
Q4-2007 50
Q1-2008 60
Q2-2008 60
Q3-2008 60
Q4-2008 60
====================================================================================================================================
New Requirement:Product column has been added.
SQL> select * from quarter_test3;
QUARTER CONFIG REP_DATE PRODUCT
Q1-2007 10 12-JAN-07 P1
Q2-2007 10 21-APR-07 P1
Q3-2007 870 14-AUG-07 P1
Q4-2007 50 15-NOV-07 P1
Q1-2008 60 02-JAN-09 P1
Q4-2006 160 02-DEC-06 P1
Q4-2006 997 02-DEC-06 P2
Q4-2007 60 14-NOV-07 P2
Q3-2007 970 14-NOV-07 P2
Q2-2007 20 21-APR-07 P2
Q1-2007 20 12-JAN-07 P2
QUARTER CONFIG REP_DATE PRODUCT
Q1-2008 70 12-JAN-08 P2
Expected Output:
Q4-2006 160 P1
Q1-2007 10 P1
Q2-2007 10 P1
Q3-2007 870 P1
Q4-2007 50 P1
Q1-2008 60 P1
Q2-2008 60 P1
Q3-2008 60 P1
Q4-2008 60 P1
Q4-2006 260 P2
Q1-2007 20 P2
Q2-2007 20 P2
Q3-2007 970 P2
Q4-2007 60 P2
Q1-2008 70 P2
Q2-2008 70 P2
Q3-2008 70 P2
Q4-2008 70 P2
My Query:
SELECT quarter,product,
CASE
WHEN qtr > TRUNC(SYSDATE, 'q')
THEN LAST_VALUE(sum_config IGNORE NULLS) OVER(ORDER BY qtr)
ELSE sum_config
END sum_config
FROM (SELECT qtr, q.qtrstr quarter,product, SUM(qt.config) sum_config
FROM (SELECT 'Q' || TO_CHAR(qtr, 'q-yyyy') qtrstr, qtr
FROM (SELECT ADD_MONTHS(ADD_MONTHS(TRUNC(SYSDATE, 'q'), -13), 3 *(LEVEL - 1)) qtr
FROM DUAL
CONNECT BY LEVEL <= 9)
ORDER BY qtr) q,
quarter_test3 qt
WHERE qt.quarter(+) = q.qtrstr
GROUP BY qtr,product, q.qtrstr)
ORDER BY substr(qtr,-4),substr(QTR,2,1)
Output:
QUARTER PRODUCT SUM_CONFIG
Q4-2006 P1 160
Q4-2006 P2 997
Q4-2007 P1 50
Q4-2007 P2 60
Q4-2008 70
Q2-2007 P1 10
Q2-2007 P2 20
Q2-2008 70
Q3-2007 P1 870
Q3-2007 P2 970
Q3-2008 70
QUARTER PRODUCT SUM_CONFIG
Q1-2007 P1 10
Q1-2007 P2 20
Q1-2008 P1 70
Q1-2008 P2 70
The query had not generated q2-2008,q3-2008,q4-2008 values [60]for P1...it had only generated q2-2008,q3-2008,q4-2008 values[70] for product P2.
Can you please advise me.You can make up the data using the model clause:
SQL> create table quarter_test3 (quarter, config, product)
2 as
3 select 'Q1-2007', 10, 'P1' from dual union all
4 select 'Q2-2007', 10, 'P1' from dual union all
5 select 'Q3-2007', 870, 'P1' from dual union all
6 select 'Q4-2007', 50, 'P1' from dual union all
7 select 'Q1-2008', 60, 'P1' from dual union all
8 select 'Q4-2006', 160, 'P1' from dual union all
9 select 'Q4-2006', 997, 'P2' from dual union all
10 select 'Q1-2007', 60, 'P2' from dual union all
11 select 'Q2-2007', 970, 'P2' from dual union all
12 select 'Q3-2007', 20, 'P2' from dual union all
13 select 'Q4-2007', 20, 'P2' from dual union all
14 select 'Q1-2008', 70, 'P2' from dual
15 /
Tabel is aangemaakt.
SQL> select 'Q' || to_char(mod(q,4) + 1) || '-' || to_char(trunc(q/4)) quarter
2 , config
3 , product
4 from quarter_test3
5 model
6 partition by (product)
7 dimension by (to_number(substr(quarter,4))*4 + to_number(substr(quarter,2,1)) - 1 q)
8 measures (config)
9 rules
10 ( config[for q from 2006*4 + 3 to 2008*4 + 3 increment 1]
11 = nvl(config[cv()],config[cv()-1])
12 )
13 order by product
14 , q
15 /
QUARTER CONFIG PR
Q4-2006 160 P1
Q1-2007 10 P1
Q2-2007 10 P1
Q3-2007 870 P1
Q4-2007 50 P1
Q1-2008 60 P1
Q2-2008 60 P1
Q3-2008 60 P1
Q4-2008 60 P1
Q4-2006 997 P2
Q1-2007 60 P2
Q2-2007 970 P2
Q3-2007 20 P2
Q4-2007 20 P2
Q1-2008 70 P2
Q2-2008 70 P2
Q3-2008 70 P2
Q4-2008 70 P2
18 rijen zijn geselecteerd.Regards,
Rob. -
Hi,
Currently we have a query (Created on Multicube - one is sales plan cube and another is Sales actuals).
When we run the query on a particular day (example: 7/10/2006), the report looks like as below:
Cal.Year/Month Sales plan Sales Actuals
Jan'06 310 305
Feb'06 280 277
Mar'06 310 309
Apr'06 300 300
MAy'06 310 305
June'06 300 305
July'06 310 90
The current report shows the whole month's Sales Plan (July'06 - 310) with Actual Sales for 9 days(for July'06 - 90). Whereas, We want to compare the sales Plan (first 9 days of the month) against the sales actuals for 9 days.
We do not have 0calday in both the cubes. Please help.
Thanks,David,
As rightly pointed out , you cannot get the plan value for 9 days if you do not have 0calday. However some things you can do...
1. Have a virtual KF which gets the number of days from the current calendar day ( system date ) to the first date of the month - this can be written with a simple exit since the first date is fixed.
2. calculate the plan value from that - pro rated plan value = plan value for month / number of days in month * number of days elapsed. If need be have the virtual KF return the ratio of number of days elapsed/number of days in the month
3. Now you can do the comparison assuming that the value of actuals will be till the current date and not beyond.
This is assuming that you can write a Virtual KF and the number of records is less enough to avoid any performance issues
Hope it helps..
Arun
Assign points if helpful
Message was edited by: Arun Varadarajan -
PROBLEM WITH HIERARCHICAL QUERY - PLEASE HELP
I have got three tables :
CREATE TABLE FIRM
(FID INTEGER NOT NULL PRIMARY KEY,
FNAME VARCHAR(40),
FTYPE VARCHAR(3),
MASTERID INTEGER );
CREATE TABLE FACULTY
(FAID INTEGER NOT NULL PRIMARY KEY,
FANAME VARCHAR(40),
FATYPE VARCHAR(3),
MASTERID INTEGER );
CREATE TABLE EMPLOYEE
(EID INTEGER NOT NULL PRIMARY KEY,
ENAME VARCHAR(20),
ESURNAME VARCHAR(20),
EJOB VARCHAR(3),
MASTERID INTEGER );
This is a hierarchical tree(or is ment to be, I,m complete rookie ) . Firm can be the root or can be slave to another firm. Faculty can be slave to firm, or to another faculty. Employee can be slave to faculty or to another employee(e.g. boss). This connections are specified by MASTERIDs.
I need to write a procedure, which parameter would be node ID. It is meant to create a VIEW from this node as if it was a root (view of a subtree).
I tried CONNECT BY clause but it works only on one table at a time and I have here three tables.
I completely don,t know how to write it. Please help.create view hierarchy as
select id, master_id, name from table1
union all
select id, master_id, name from table2
union all
select id, master_id, name from table3
Then do your connect by query against hierarchy.
It will not work in 8i (connect by on views not allowed), so you will need to materialize the view.
Kirill -
Picture hyperlinks not working when published? Please help....
Some of the hyperlinks to my pictures do not work when I publish to my folder. I´ve tried to empty Safaris cache but it still doesn´t work. Please help me, pretty urgent....
hi briebrie,
this is common mistake, see my post in this thread:
http://discussions.apple.com/message.jspa?messageID=4004970#4004970
The work around is to leave iWeb default nav bar and header enabled, add your home made nav bar (outside/below of iWeb default nav bar).
Then turn off iWeb nav bar and header when you are done. -
Using case statement in merge when matched
Hi,
I want to use case statement in the when matched clause of merge statement to ensure that I update only those fields that are undated.
create table TEST1
NAME1 VARCHAR2(25),
NAME2 VARCHAR2(25),
ID NUMBER not null
create table TEST2
ID NUMBER not null,
ID2 NUMBER not null,
NAME1 VARCHAR2(25),
NAME2 VARCHAR2(25)
merge into test1 t1
using
test2 t2
ON (t1.id = t2.id)
when matched
then
case
when t1.name1 != t2.name1
then
update set t1.name1 != t2.name1
when t1.name2 != t2.name2
then
update set t1.name2 != t2.name2
else
null;
end
it does not work and raises invalid sql command. Any idea how can I do that?
Thanks.
Sajid
Edited by: 808255 on Nov 12, 2010 4:22 AMHi
In that case you would have to use multiple statements and you may as well just use UPDATE instead of MERGE. Also, are you sure that you aren't trying to to fix a problem that doesn't actually exist.
Think about where the execution time is going to come from...
I would be tempted to do 1 UPDATE like this...
UPDATE test1 t1
SET (t1.name1,
t1.name2) = (SELECT t2.name1,
t2.name2
FROM test2 t2
WHERE t1.id = t2.id
AND (t1.name1 != t2.name1
OR t1.name2 != t2.name2))If you get specific performance issue with this, then post an explain plan and trace and I'll have a look.
I don't this the cost of the update is going to be as great as you think.
Cheers
Ben
Maybe you are looking for
-
ILife '08, LP8, FCS 2 - issues & what is new in GB 08?
I have iLife 06 on my Mac along with LP8 and FCS 2. Would like to know: 1. What is the difference between GB 3 and GB 08? 2. Will installing iLife 08 mess up LP8 and/or FCS 2 samples? Thanks, Rob. Message was edited by: Rob A.
-
Use of CS operator in SELECT... WHERE clause not allowed
Hi all gurus, quite a dumb question, but since I'm facing the issue... I need to access a standard DB table with some selection criteria , in particular I'd like to extract all the entries where the field NAME contains a specific substring. Since the
-
Premiere CS5 running very slow on powerful PC
I know this thread has been done before but i really need help. I'll start with the system specs. win 7 64bit NVIDIA Quadro FX 5800 (driver updated) Intel Xeon X5680 3.33GHz 24 GB RAM The computer should have no issues with basic editing but it stru
-
IPhone 6 - Intermittent Loss Of Sound
Hi, My handset has just recently started loosing sound via the speakers/headphones....totally. The phone is up to date on iOS8, it is always in a case and is very much looked after. It hasn't been dropped or exposed to water (other than a few drops
-
After upgrading to Mounton Lion McBook pro does not sleep with lid closed
Instead it gets very hot! Have tried to adjust "energy savings" to no avail. Please help!