ANSI join kick off session Oracle
Under query works fine in 11I instance but not in R12. If I remove the text "INNER JOIN" and "LEFT OUTER JOIN" and replace it with the old syntax, then it's job to join. Here join ANSI is used if confused about how convert ANSI join old syntax.
WITH mo_rsrv
AS (SELECT / * + materialize * /)
Mr.organization_id,
Mr.inventory_item_id,
Mr.subinventory_code,
WLP.attribute3 document_type,
Mr.locator_id,
Mr.demand_source_line_id,
Mr.demand_source_name,
Mr.attribute6,
SUM (primary_reservation_quantity)
primary_reservation_quantity
OF mtl_reservations m., wwt_lookups wlp
WHERE mr.demand_source_type_id = wlp.attribute2
AND wlp.lookup_type = 'XXXX '.
AND wlp.attribute1 = 'PO '.
Mr.organization_id GROUP,
Mr.inventory_item_id,
Mr.subinventory_code,
WLP.attribute3,
Mr.locator_id,
Mr.demand_source_line_id,
Mr.demand_source_name,
Mr.attribute6),
po_ship_rec
AS (SELECT polla.ship_to_organization_id,
Polla.po_header_id,
Polla.po_line_id,
SUM (polla.quantity - NVL (polla.quantity_cancelled, 0))
quantity
OF apps.po_line_locations_all polla
-WHERE po_header_id = 191275
Polla.ship_to_organization_id GROUP,
Polla.po_header_id,
Polla.po_line_id)
SELECT "PO" document_type,
poha. Segment1,
Line_number, To_char (pola.line_num),
Ship_set NULL,
Msik.concatenated_segments ordered_item,
Pola.attribute4 config,
Pola.attribute14 material_designator,
Pola.CREATION_DATE needby_date,
po_ship_rec. Quantity,
mo_rsrv.primary_reservation_quantity,
"reservation_status,.
"total_onhand,.
poha.po_header_id,
Pola.po_line_id,
po_ship_rec.ship_to_organization_id,
Pola.item_id,
Ship_set_id TO_NUMBER (NULL),
Top_model_id TO_NUMBER (NULL),
Pola.last_update_date,
Pola.last_updated_by,
Pola.CREATION_DATE,
Pola.created_by
OF po_ship_rec
INNER JOIN apps.po_headers_all poha
WE (poha.po_header_id = po_ship_rec.po_header_id)
INNER JOIN apps.po_lines_all pola
WE (pola.po_line_id = po_ship_rec.po_line_id)
INNER JOIN apps.mtl_system_items_kfv reform
WE (msik.organization_id =
po_ship_rec.ship_to_organization_id
AND msik.inventory_item_id = pola.item_id)
LEFT OUTER JOIN mo_rsrv
WE (mo_rsrv.demand_source_name = poha.segment1
AND mo_rsrv.attribute6 = pola.po_line_id
AND mo_rsrv.organization_id =
po_ship_rec.ship_to_organization_id
AND mo_rsrv.inventory_item_id = pola.item_id)
WHERE 1 = 1;
Suspicion of MATERIALIZATION is undocumented and may cause errors, or bad results. Your query works if you remove the indicator?
SY.
Tags: Database
Similar Questions
-
Note a 'strange' behavior when you use ANSI joins in Oracle and I was wondering if there are still problems with their use in Oracle (11 g)
Basically I have a MV_F_PRODUCT_ACTUAL vision, which is defined as a self-join to work the point in time for a product like the following values:
i.e. use ANSI joined to solve on the beaches of different dates between our F_BOOKING and F_PRODUCT tables. I cut the code from there as much as possible while retaining the main features.SELECT F_PRODUCT_PREV.i_SK_Product, F_PRODUCT_PREV.i_SK_Version, F_PRODUCT_PREV.i_SK_VersionDate, D_CALENDAR.i_SK_Date AS i_SK_PointInTimeDate, F_PRODUCT_PREV.i_SK_Current, SUM(F_BOOKING.f_NoPax) AS f_NoPax FROM F_PRODUCT F_PRODUCT_PREV LEFT JOIN F_PRODUCT F_PRODUCT_NEXT ON F_PRODUCT_NEXT.i_SK_Product=F_PRODUCT_PREV.i_SK_Product AND F_PRODUCT_NEXT.i_SK_Version=F_PRODUCT_PREV.i_SK_Version+1 LEFT JOIN D_CALENDAR ON D_CALENDAR.i_SK_Date BETWEEN F_PRODUCT_PREV.i_SK_VersionDate AND COALESCE(F_PRODUCT_NEXT.i_SK_VersionDate-1,TO_NUMBER(TO_CHAR(TRUNC(SYSDATE),'YYYYMMDD'))) LEFT JOIN ( SELECT F_BOOKING.i_SK_Product, F_BOOKING.i_SK_Bkg, D_CALENDAR.i_SK_Date AS i_SK_VersionDate, MAX(F_BOOKING.i_SK_Version) AS i_SK_BookingVersion FROM D_CALENDAR INNER JOIN F_BOOKING ON F_BOOKING.i_SK_VersionDate<=D_CALENDAR.i_SK_Date GROUP BY F_BOOKING.i_SK_Product, F_BOOKING.i_SK_Bkg, D_CALENDAR.i_SK_Date ) F_BOOKING_ON_DATE ON F_BOOKING_ON_DATE.i_SK_Product=F_PRODUCT_PREV.i_SK_Product AND F_BOOKING_ON_DATE.i_SK_VersionDate=D_CALENDAR.i_SK_Date LEFT JOIN F_BOOKING ON F_BOOKING.i_SK_Bkg=F_BOOKING_ON_DATE.i_SK_Bkg AND F_BOOKING.i_SK_Version=F_BOOKING_ON_DATE.i_SK_BookingVersion
Now, if I question this view with ANSI joins as follows:
Then, the query returns results in less than a second. However, our report default application using joins in Oracle style as follows:SELECT D_PRODUCT.A_PRODUCTCODE, D_PRODUCT.A_PRODUCTNAME, D_PRODUCT.A_PRODUCTTYPE, sum(NVL(MV_F_PRODUCT_ACTUAL.F_NOPAX,0)), sum(F_PRODUCT.F_ACTIVEPAXRANGE) FROM MV_F_PRODUCT_ACTUAL LEFT JOIN D_PRODUCT ON D_PRODUCT.i_SK_Product=MV_F_PRODUCT_ACTUAL.i_SK_Product LEFT JOIN D_CALENDAR ON D_CALENDAR.i_SK_Date=MV_F_PRODUCT_ACTUAL.i_SK_PointInTimeDate LEFT JOIN F_PRODUCT ON F_PRODUCT.i_SK_Product=MV_F_PRODUCT_ACTUAL.i_SK_Product AND F_PRODUCT.i_SK_Version=MV_F_PRODUCT_ACTUAL.i_SK_Version WHERE D_CALENDAR.Calendar_Date='01/Apr/2010' GROUP BY D_PRODUCT.A_PRODUCTCODE, D_PRODUCT.A_PRODUCTNAME, D_PRODUCT.A_PRODUCTTYPE;
And this query runs for hours without result.SELECT D_PRODUCT.A_PRODUCTCODE, D_PRODUCT.A_PRODUCTNAME, D_PRODUCT.A_PRODUCTTYPE, sum(NVL(MV_F_PRODUCT_ACTUAL.F_NOPAX,0)), sum(F_PRODUCT.F_ACTIVEPAXRANGE) FROM D_PRODUCT, MV_F_PRODUCT_ACTUAL, F_PRODUCT, D_CALENDAR WHERE ( D_PRODUCT.i_SK_Product=MV_F_PRODUCT_ACTUAL.i_SK_Product ) AND ( D_CALENDAR.i_SK_Date=MV_F_PRODUCT_ACTUAL.i_SK_PointInTimeDate ) AND ( F_PRODUCT.i_SK_Product=MV_F_PRODUCT_ACTUAL.i_SK_Product AND F_PRODUCT.i_SK_Version=MV_F_PRODUCT_ACTUAL.i_SK_Version ) AND ( D_CALENDAR.Calendar_Date='01/Apr/2010' ) GROUP BY D_PRODUCT.A_PRODUCTCODE, D_PRODUCT.A_PRODUCTNAME, D_PRODUCT.A_PRODUCTTYPE;
As far as I can tell, the two queries are functionally identical, so I left I was wondering if there is an additional optimization of the request being made by the first (ANSI at the bottom) query that is somehow not possible for the second syntax. Oracle would not 'smart' merge query in the view with the outer query in one case but not the other?
I tried this create a materialized view (where the name), but the time to refresh an hour and a half is just too long to comfortably in our window of batch during the night. There are other optimizations of brute force, I could consider (staging of the motion of inline F_BOOKING_ON_DATE being the obvious one), but I'm afraid that if there is a fundamental incompatibility between the two join strategies that other similar problems can occur in our live environment without warning.
Someone at - he had similar experiences?
Published by: user11995414 on August 21, 2012 09:32As far as I can tell, the two motions are functionally identical,
they are not.
In ANSI variant it is LEFT JOIN in the Oracle variant, that I don't see(+)
.
Published by: user11181920 on August 21, 2012 14:44
-
Join ANSI join VS. Oracle (old join)
Hello
I have a request on the old version of join for oracle
its not take more then 30 dry running, I tried to change to an ANSI join query
but then he tooks 400 seconds, I would like to know how Oracle is to solve the two querys?
Im running the application on a different server where the tables.
These are the querys
Qry 1 - old join
Select cp.account_no,
CPC.id_value Subscr_no,
cce.Component_id,
CCE.active_dt,
CP. Package_instance_id_serv
Of Cmf_Packages@arborp01 cp,.
Cmf_Package_Components@arborp01 code of criminal procedure
cmf_component_elements@arborp01 EAC,
customer_contracts@arborp01 cc
Where cp. Package_instance_id = cpc. Package_instance_id
And cp. Package_instance_id_serv = cpc. Package_instance_id_serv
And cpc.component_instance_id = cce.component_instance_id
And cpc.component_instance_id_serv = cce.component_instance_id_serv
And cce.association_id = cc.tracking_id
And cpc.Component_id in (60584,90474,90475)
And the EAC. Package_status = 1
And the EAC. Inactive_dt is null
And cce.association_type = 2
Qry2 - join ANSI
Select
CP.account_no,
CPC.id_value Subscr_no,
cce.Component_id,
CCE.active_dt,
CP. Package_instance_id_serv
Of Cmf_Packages@arborp01 cp
Join Cmf_Package_Components@arborp01 cpc
on (cp. Package_instance_id = cpc. Package_instance_id
And cp. Package_instance_id_serv = cpc. Package_instance_id_serv)
Join cmf_component_elements@arborp01 EAC
on (cpc.component_instance_id = cce.component_instance_id
And cpc.component_instance_id_serv = cce.component_instance_id_serv)
Join Customer_contracts@arborp01 cc on cce.association_id = cc.tracking_id
Where cpc.Component_id in (60584,90474,90475)
And the EAC. Package_status = 1
And the EAC. Inactive_dt is null
And cce.association_type = 2
An aplogize for my eanglish.
Thank youDo you mean that the remote servers are running 8i?
8i supported SQL 99 join syntax. So I would be quite surprised if forcing the instance of Oracle 9i local to do joins, representing the query Exchange plan.
Justin
-
From what I've been reading is preferable to use the new syntax (don't know how is it news)
The ANSI join syntax was new to Oracle in Oracle 8i in 1998 - that is 15 years old.
It can produce more readable code and is also much more readable and less human-source of errors for outer joins.
The ANSI format allows an outer join between several tables in a way the old (+) syntax specific to oracle does not and introduced the JOIN FULL OUTER you should use very rarely.
You should not use NATURAL JOIN in code - add columns not related to the tables involved can give very different results.
There have not been important bugs for ANSI joins in Oracle from Oracle 10.2 set up about 8 years ago.
As Paul says, the part on should be the criteria to join between the tables. Did clause should be the filtering of the joined tables.
So assuming start_date and end_date in_property_id are variable
SELECT resv_num, unit_date
OF p_resv_unit ru
INNER JOIN p_pm_unit_night pun
ON pun.resv_unit_id = ru.resv_unit_id
WHERE pun.property_id = in_property_id
AND pun.unit_date BETWEEN start_date AND end_date
AND pun.pm_unit_num = cvUnitNum;
If start_date and end_date are the columns of p_resv_unit the query would be:
SELECT resv_num, unit_date
OF p_resv_unit ru
INNER JOIN p_pm_unit_night pun
ON pun.resv_unit_id = ru.resv_unit_id AND pun.unit_date BETWEEN ru.start_date AND ru.end_date
WHERE pun.property_id = in_property_id
AND pun.pm_unit_num = cvUnitNum;
Inner join queries work with criteria in the wrong place, but they are harder to read. Outer joins do not work unless you put the criteria in the right place.
-
old script with joins instead of ansi joins
In 9i OWB when I generate the intermediate result script, it is generateing join in the OLD style as conditions below.
a.ID = b.id (+)
But in Oracle 11 g, it raises the join conditions in the Ansi joins as below
a left outer join b on (a.id = b.id)
Is there a way to generate the intermediate result script in an old style in OWB 11 g?
Help, please.I did a quick post here showing ownership.
https://blogs.Oracle.com/warehousebuilder/entry/owb_ansi_and_oracle_sqlSee you soon
David -
Need clarification on the ANSI joins
Hi all
I need some clarification on the ANSI join I am building to avoid an error when I try to run the same in standard join.
With standard join, I get the error ORA-01417: a table can be external joined as another table.
Regular join condition:
Select null
Of
land_event_device_fraud dealer update,-T1
land_event_device_upgrade T2, - New Subscriber first Set
syn_intg_event_device_state T3, - subscribed existing
land_event_device_upgrade T4 - new Subscriber Second Set
WHERE T1.event_id = T2.event_id (+) AND T1.rate_plan_id = T2.rate_plan_id (+)
AND T1.event_id = T3.event_id (+) AND T1.rate_plan_id = T3.rate_plan_id (+)
AND T4.event_id = T1.event_id (+) AND T4.event_id = T1.rate_plan_id (+)
AND T4.event_id = T3.event_id (+) AND T4.event_id = T3.rate_plan_id (+);
-Get the error ORA-01417.
Replaced the join above with ANSI join
SELECT NULL
OF land_event_device_fraud t1
LEFT OUTER JOIN t2 land_event_device_upgrade
WE (t1.event_id = t2.event_id AND t1.rate_plan_id = t2.rate_plan_id)
LEFT OUTER JOIN syn_intg_event_device_state t3
WE (t1.event_id = t3.event_id AND t1.rate_plan_id = t3.rate_plan_id).
land_event_device_upgrade t4
LEFT OUTER JOIN land_event_device_fraud t5
WE (t4.event_id = t5.event_id AND t4.rate_plan_id = t5.rate_plan_id)
LEFT OUTER JOIN syn_intg_event_device_state t6
WE (t4.event_id = t6.event_id AND t4.rate_plan_id = t6.rate_plan_id);
I want to know if the ANSI join is goig work properly or it will give me any Cartesian production information.
Appreciate your help here.
Thank you
MK.Hello
Maldini says:
Hi allI need some clarification on the ANSI join I am building to avoid an error when I try to run the same in standard join.
With standard join, I get the error ORA-01417: a table can be external joined as another table.
Regular join condition:
Select null
Of
land_event_device_fraud dealer update,-T1
land_event_device_upgrade T2, - New Subscriber first Set
syn_intg_event_device_state T3, - subscribed existing
land_event_device_upgrade T4 - new Subscriber Second Set
WHERE T1.event_id = T2.event_id (+) AND T1.rate_plan_id = T2.rate_plan_id (+)
AND T1.event_id = T3.event_id (+) AND T1.rate_plan_id = T3.rate_plan_id (+)
AND T4.event_id = T1.event_id (+) AND T4.event_id = T1.rate_plan_id (+)
AND T4.event_id = T3.event_id (+) AND T4.event_id = T3.rate_plan_id (+);-Get the error ORA-01417.
Replaced the join above with ANSI join
SELECT NULL
OF land_event_device_fraud t1
LEFT OUTER JOIN t2 land_event_device_upgrade
WE (t1.event_id = t2.event_id AND t1.rate_plan_id = t2.rate_plan_id)
LEFT OUTER JOIN syn_intg_event_device_state t3
WE (t1.event_id = t3.event_id AND t1.rate_plan_id = t3.rate_plan_id).
land_event_device_upgrade t4
LEFT OUTER JOIN land_event_device_fraud t5
WE (t4.event_id = t5.event_id AND t4.rate_plan_id = t5.rate_plan_id)
LEFT OUTER JOIN syn_intg_event_device_state t6
WE (t4.event_id = t6.event_id AND t4.rate_plan_id = t6.rate_plan_id);You mix ANSI joins and the old joints. It's very confusing. Use all of one type or the other.
>I want to know if the ANSI join is goig work properly or it will give me any Cartesian production information.
What happens when try you it? Is it produces the results you want?
Whenever you have any questions, post a small example of data (CREATE TABLE and INSERT statements) and the results desired from these data. Explain how you get these results from these data.
Always tell what version of oracle you are using.
See the FAQ forum {message identifier: = 9360002}Why the SELECT clause includes only NULL? Is that going to serve as an EXISTS subquery? If so, why bother to make the outer joins, and why do you care if it is a Cartesian product? What is the query to go for?
For the purposes of debugging, you can include something that you see in the SELECT clause. -
JOIN the traditional ANSI JOIN VS.
I am running Oracle 11 g R2 on my Win7 home x 64 Enterprise for a relational data base class.
An exercise said to display the id of shopping cart, product id, product name and description of the product for all items ordered using a traditional join and an ANSI join.
Traditional join:
SELECT p.productname, p.description, bi.idproduct and bi.idbasket
of BB_BASKETITEM bi, BB_PRODUCT p
where bi.idproduct = p.idproduct;
Join ANSI:
SELECT productname, description, idproduct and idbasket
of BB_BASKETITEM
JOIN INTERNAL BB_PRODUCT
using (idProduct);
Both produce the same results.
The next exercise said to add the name of the customer for both queries. I got the traditional join to work:
SELECT s.lastname as "Customer Name", bi.idbasket, bi.idproduct, p.productname, p.description
BI BB_BASKETITEM, BB_PRODUCT p, BB_SHOPPER s, BB_BASKET b
where bi.idproduct = p.idproduct
and bi.idbasket = b.idbasket
and b.idshopper = s.idshopper;
but I can't understand how to convert the traditional join in ANSI format.
I checked the docs of the Oracle, but I can't find an example that uses more than two tables. I searched in the OTN forums, without a moment of ' AHA! '. One manual sorta, kinda discusses vs ANSI joins traditional.
I have tried to provide the sample results, but all turned to mush in the preview. My apologies.
Thanks for your help.
Provisions of tables are:
CREATE TABLE BB_Product)
idProduct number (2),
ProductName varchar2 (25).
Description varchar2 (100),
ProductImage varchar2 (25).
Price number (6.2),
SaleStart date,
Date of SaleEnd,
SalePrice number (6.2),
Number (1) active,.
Number (1) recommended.
Date of FeatureStart,
Date of FeatureEnd,
Type char(1),
idDepartment number (2),
Prod_id_pk KEY (idProduct) PRIMARY, the CONSTRAINT
CONSTRAINT prod_idDept_fk FOREIGN KEY (idDepartment)
REFERENCES BB_Department (idDepartment));
CREATE TABLE BB_Shopper)
idShopper number 4,
First name varchar2 (15).
LastName varchar2 (20).
Address varchar2 (40),
City varchar2 (20).
(2) tank, the State
Code postal varchar2 (15).
Phone varchar2 (10),
Fax varchar2 (10),
E-mail varchar2 (25).
Username varchar2 (8).
Varchar2 (8) password,.
Number 4 of cookie by DEFAULT 0,
date of dtEntered by DEFAULT SYSDATE,
Varchar2 (15) of the province.
Country varchar2 (15).
CONSTRAINT shopper_id_pk KEY (idShopper) primary SCHOOL);
CREATE TABLE bb_Basket)
idBasket number (5),
Quantity number (2),
idShopper number 4,
OrderPlaced number (1).
Total part number (7.2).
The number total (7.2).
Number (5.2) of the expedition.
Number (5.2) tax.
date of dtCreated by DEFAULT SYSDATE,
Promo number (2),
ShipFirstName varchar2 (10),
ShipLastName varchar2 (20).
ShipAddress varchar2 (40),
ShipCity varchar2 (20).
ShipState varchar2 (2),
ShipZipCode varchar2 (15).
ShipPhone varchar2 (10),
ShipFax varchar2 (10),
ShipEmail varchar2 (25).
BillFirstName varchar2 (10),
BillLastName varchar2 (20).
BillAddress varchar2 (40),
BillCity varchar2 (20).
BillState varchar2 (2),
BillZipCode varchar2 (15).
BillPhone varchar2 (10),
BillFax varchar2 (10),
BillEmail varchar2 (25).
date of dtOrdered by DEFAULT SYSDATE,
ShipProvince varchar2 (20).
ShipCountry varchar2 (20).
BillProvince varchar2 (20).
BillCountry varchar2 (20).
CardType char(1),
CardNumber varchar2 (20).
ExpMonth tank (2),
ExpYear char (4),
CardName varchar2 (25).
char (1) default 'n' shipbill,
Default char (1) ShipFlag 'n',
Bskt_id_pk KEY (idBasket) PRIMARY, the CONSTRAINT
CONSTRAINT bskt_idshopper_fk FOREIGN KEY (idShopper)
REFERENCES bb_Shopper (idShopper));
CREATE TABLE bb_basketItem)
idBasketItem number (2),
idProduct number (2),
Price number (6.2),
Quantity number (2),
idBasket number (5),
option 1 number (2),
option2 number (2),
CONSTRAINT bsktitem_id_pk PRIMARY KEY (idBasketItem).
CONSTRAINT bsktitem_bsktid_fk FOREIGN KEY (idBasket)
REFERENCES bb_Basket (idBasket),
CONSTRAINT bsktitem_idprod_fk FOREIGN KEY (idproduct)
REFERENCES bb_Product (idproduct));I just want to say that I appreciate your question well formatted and fully formed :-) Thanks for providing descriptions of table and oracle version number.
Try this:
SELECT s.lastname as "Customer Name", bi.idbasket, bi.idproduct, p.productname, p.description from BB_BASKETITEM bi join BB_PRODUCT p on (p.idproduct = bi.idproduct) join BB_BASKET b on (b.idbasket = bi.idbasket) join BB_SHOPPER s on (s.idshopper = b.idshopper);
-
Manually kick off of a simple pre-packaged ETL?
Hello world
I hope it's an easy question to answer. I want to run some ETLs manually through Workflow Manager. But when I do, they fail with the error "cannot find the settings file.
Is there a way I can easily just kick off one of these ETLs for testing purposes?
Thank you!
-JoeThere are two ways to achieve this.
1 copy the parameter in the $pmserver / infa_shared / directory SrcFiles, then run the task.
2. create new Sessions by cloning that you run from CAD and set the settings to the SQ, replacing the $$ LAST_UPDATE_DATE, $$ INITIAL_EXTRACT_DATE, etc. In this way it does not affect your SQ defined at the level of the mapping.
Change connection settings to those defined in--> relational connections to point to the Source & target. Plug into a single workflow if you have all the dependenciesThen the kickoff of the workflow.
-
I need for everyone once a request to do a global change. Can someone tell me how? I have looked everywhere in the Administration area of the Apex and cannot find anything else than reports.
TIA
Published by: userRRRYB on July 28, 2011 18:16Hello
Change the availability of the applications
http://download.Oracle.com/docs/CD/E17556_01/doc/user.40/e15517/BLDR.htm#sthref438Kind regards
Jari -
I am able to start a session, but I was not able to join by signing another pc usage. usually it is said there are already 2 users already signed.
When you build the link, a small chat window should open at the bottom right. Which will automatically join you to the House.
You can then share this link with anyone, or another computer, and they should be able to join.
Note that for links build you, if you click on the link and have it in a tab, which currently stops anyone else to join.
We are working on improving this in a future release.
-
Update/join script to the oracle server
Im trying to create a script using two tables in my oracle server.
Developer SQL im trying to use these two different tables
Table 1: conductorinfo
Table2: calkva
I want to join the two tables based on two fields:
Condsize
Condmatl
(because the two tables have these fields) And based on these games of field, update the field conductorinfo of the table "calckva", because currently we have not these data in the conductorinfo table
This is the script I came up with:
UPDATE conductorinfo
JOIN INTERNAL Calkva
ON conductorinfo.condsize = calkva.condsize
AND conductorinfo.condmatl = calkva.condmatl
SET conductorinfo.calkva = calkva.calculatedkva
WHERE conductorinfo.condsize = calkva.condsize
AND conductorinfo.condmatl = calkva.condmatl
Then I read this update/join cannot be used with an oracle server
Any suggestions?
Hello
Here's a way you can use the MERGE:
MERGE INTO dst conductorinfo
With the HELP of calkva CBC
WE (dst.condsize = src.condsize
AND dst.condmatl = src.condmatl
)
WHEN MATCHED THEN UPDATE
SET dst.calkva = dst.calculatedkva
;
-
Joining several tables in Oracle DB
I have the following tables.
1 AddProject
-PROJID
-projName
2 AddLab
-Labrador
-teacher
3 ProjLabAssociation
-PROJID
-Labrador
4 AddResearchArea
-raID
-raName
5 ProjRAAssociation
-PROJID
-raID
AddProject is associated with tables-AddLab and AddResearchArea
ProjLabAssociation and ProjRAAssociation are the association of the tables that contain the primary key of the corresponding tables. The two fields in these 2 tables are primary keys.
If AddProject has 3 entrances - (Proj1, ProjectA) (Proj2 ProjectB), (Proj3, ProjectC)
AddLab has 2 entrances - (Lab1, Bangalore), (Lab2, Chennai)
AddResearchArea has 2 inputs - AM1 (Green Computing) (RA2, Cloud Computing)
ProjLabAssociation has 2 entrances - (Proj2 Lab1), (Proj3, Lab1)
ProjRAAssociation has 3 entries - (Proj2 RA1), (Proj3, AM1), (Proj3, RA2)
If I ask by AddLab given for (Lab1, Bangalore), I should get the following columns in the result table
--------------------------------------------------------------------------------------------------------------------------------
Table2ID | Table2Name | Table3ID | Table3Name | Table1ID | Table1Name
Lab1. Bangalore | RA1 | Green Computing | Proj2 | Project b
Lab1. Bangalore | RA1 | Green Computing | Proj3 | Project c
Lab1. Bangalore | RA2 | Cloud Computing | Proj3 | Project c
--------------------------------------------------------------------------------------------------------------------------------
I tried the following commands but I m getting the expected result
1.
A SQLException exception is thrown by saying - java.sql.SQLException: ORA-01417: a table can be external joined as another tableSELECT * FROM AddLab al, ProjLabAssociation pl, AddProject ap WHERE al.labID = pl.labID(+) and ap.projID = pl.projID(+);
--------------------------------------------------------------------------------------------------------------------------------
2.
I do not get results expcted hereSELECT * FROM AddLab,AddProject,AddResearchArea WHERE labID in (select al.labID from ProjLabAssociation pl,AddLab al where al.labID = pl.labID) AND projID in (select ap.projID from ProjLabAssociation pl,Addproject ap where ap.projID = pl.projID) AND themeID in (select ar.raID from ProjRAAssociation pr, AddResearchArea ar where ar.raID = pr.raID) AND projID in (select ap.projID from ProjRAAssociation pr,Addproject ap where ap.projID = pr.projID) ORDER BY labID;
--------------------------------------------------------------------------------------------------------------------------------
Oracle version: 9i 10g / 11g
Can anyone help me in this.
Published by: user9205634 on December 22, 2011 03:40Hello
Below the code gives the result
with table1 as ( select 'Proj1' as table1id,'ProjectA' as table1name from dual union all select 'Proj2' as table1id,'ProjectB' as table1name from dual union all select 'Proj3' as table1id,'ProjectC' as table1name from dual union all select 'Proj4' as table1id,'ProjectD' as table1name from dual ) ,table2 as ( select 'Lab1' as table2id,'Bangalore' as table2name from dual union all select 'Lab2' as table2id,'Chennai' as table2name from dual union all select 'Lab3' as table2id,'Delhi' as table2name from dual ) , table3 as ( select 'RA1' as table3id,'Green Computing' as table3name from dual union all select 'RA2' as table3id,'Cloud Computing' as table3name from dual ) ,table1table2 as ( select 'Proj2' as table1id,'Lab1' as table2id from dual union all select 'Proj3' as table1id,'Lab1' as table2id from dual union all select 'Proj3' as table1id,'Lab2' as table2id from dual union all select 'Proj4' as table1id,'Lab3' as table2id from dual ) ,table1table3 as ( select 'Proj2' as table1id,'RA1' as table3id from dual union all select 'Proj3' as table1id,'RA1' as table3id from dual union all select 'Proj3' as table1id,'RA2' as table3id from dual ) select t2.table2id,t2.table2name,t3.table3id,t3.table3name,t1.table1id,t1.table1name from table1 t1,table2 t2,table3 t3,table1table2 jt1t2,table1table3 jt1t3 where jt1t2.table2id=t2.table2id and t1.table1id=jt1t2.table1id and jt1t3.table1id(+)=jt1t2.table1id and t3.table3id(+)=jt1t3.table3id order by t2.table2name,t3.table3id;
TABLE2ID TABLE2NAME TABLE3ID TABLE3NAME TABLE1ID TABLE1NAME -------- ---------- -------- --------------- -------- ---------- Lab1 Bangalore RA1 Green Computing Proj2 ProjectB Lab1 Bangalore RA1 Green Computing Proj3 ProjectC Lab1 Bangalore RA2 Cloud Computing Proj3 ProjectC Lab2 Chennai RA1 Green Computing Proj3 ProjectC Lab2 Chennai RA2 Cloud Computing Proj3 ProjectC Lab3 Delhi Proj4 ProjectD 6 rows selected
Kind regards
Prabhu -
Hi all
I have this query in which I used ansi, not an expert but joins on joins ansi... had know abt joins ansi only today
I'm ambigously columnSELECT abc.vendor_number, abc.vendor_name, api.invoice_amount, api.invoice_date, api.invoice_type_lookup_code, api.invoice_num, avp.prepay_number, api.description, --,avp.INVOICE_CURRENCY_CODE CCY, aup.prepay_amount_applied, aup.prepay_amount_remaining, SUM (-avp.prepay_amount_remaining * NVL (api.exchange_rate, 1) ) prepaid_available, '1234' voucher_number FROM ap_invoices_v api INNER JOIN ap_invoice_distributions_v aid ON ( api.invoice_id = aid.invoice_id AND api.invoice_type_lookup_code = 'PREPAYMENT' AND api.invoice_num = '5' ), ap_invoices_v api LEFT OUTER JOIN ap_apply_prepays_v avp ON (api.invoice_id = avp.invoice_id ), ap_invoices_v api INNER JOIN ap_checks_v abc ON (abc.vendor_id = api.vendor_id ), ap_invoice_payments abb LEFT OUTER JOIN ap_apply_prepays_v avp ON (abb.invoice_id = avp.invoice_id ), ap_invoice_distributions_v aid LEFT OUTER JOIN ap_unapply_prepays_v aup ON (aid.invoice_distribution_id = aup.prepay_distribution_id ), ap_unapply_prepays_v aup LEFT OUTER JOIN ap_apply_prepays_v avp ON (aup.prepay_distribution_id = avp.invoice_distribution_id ), ap_invoices_v api INNER JOIN ap_invoice_payments abb ON (abb.invoice_id = api.invoice_id )
defined in the select clause, is there another way to refer to the columns?
kindly Guide
thanking in advance
Published by: makdutakdu on December 20, 2011 11:28Hello
SELECT abc.vendor_number, abc.vendor_name, api.invoice_amount, api.invoice_date, api.invoice_type_lookup_code, api.invoice_num, avp.prepay_number, api.description, --,avp.INVOICE_CURRENCY_CODE CCY, aup.prepay_amount_applied, aup.prepay_amount_remaining, SUM (-avp.prepay_amount_remaining * NVL (api.exchange_rate, 1) ) prepaid_available, '1234' voucher_number FROM ap_invoices_v api INNER JOIN ap_invoice_distributions_v aid ON ( api.invoice_id = aid.invoice_id AND api.invoice_type_lookup_code = 'PREPAYMENT' AND api.invoice_num = '5' ) LEFT OUTER JOIN ap_apply_prepays_v avp ON (api.invoice_id = avp.invoice_id ) INNER JOIN ap_checks_v abc ON (abc.vendor_id = api.vendor_id) INNER JOIN ap_invoice_payments abb ON (abb.invoice_id =api.invoice_id) LEFT OUTER JOIN ap_apply_prepays_v avp ON (abb.invoice_id =avp.invoice_id) LEFT OUTER JOIN ap_unapply_prepays_v aup ON (aid.invoice_distribution_id = aup.prepay_distribution_id), LEFT OUTER JOIN ap_apply_prepays_v avp ON (aup.prepay_distribution_id =avp.invoice_distribution_id)
You join ap_apply_prepays_v three times, and you get the error, because you are still using the same alias.
However, this triple join is incorrect. Try
FROM ap_invoices_v api JOIN ap_invoice_distributions_v aid ON (api.invoice_id = aid.invoice_id) JOIN ap_checks_v abc ON (abc.vendor_id = api.vendor_id) JOIN ap_invoice_payments abb ON (abc.check_id = abb.check_id AND abb.invoice_id = api.invoice_id) LEFT JOIN ap_unapply_prepays_v aup ON (aid.invoice_distribution_id = aup.prepay_distribution_id) LEFT JOIN ap_apply_prepays_v avp ON (api.invoice_id=avp.invoice_id AND aup.prepay_distribution_id = avp.invoice_distribution_id) WHERE api.invoice_type_lookup_code = 'PREPAYMENT' AND api.invoice_num = '5'
Concerning
Marcus -
list down session oracle connected for more than 24 hours
Hi Experts,
Please provide the request in order to get the session active and inactive which was held in the oracle database and consume physical resources.
Thanks in advance.Note: Please refer to last_call_et and v$ session
----------
Sybrand Bakker
Senior Oracle DBA -
Need help with the ANSI Join syntax
Version: 11.1.0.7
I have my select statement that returns 3000 lines and looks like
I want to convert it to ANSI SQL, because it must be able to Hibernate, and the developer says that Hibernate include only ANSI SQL. I tried something likeselect .. from tab1 a,tab2 b,tab3 c where a.c1=b.c1 and b.c2 = c.c2(+) and ... group by ..
I felt bad and it turned out to be the same. It returns no rows. Please help with the correct syntax.select .. from tab1 a INNER JOIN tab2 b ON a.c1=b.c1 LEFT OUTER JOIN tab3 c ON b.c2=c.c2 where ... group by ..
I'm not sure, sorry, because it's certainly the ANSI equivalent to the non-ANSI.
Would you have examples of queries and data that you can reproduce the problem with, and that we could analyze?
Published by: Seanmacgc on July 15, 2009 12:48
If there is no Clause WHERE conditions in the original that are included in the ANSI version of the query in the WHERE Clause for the EXTERNAL table itself joined, then that could transform the JOIN JOIN internally, that is, all the filters on the EXTERNAL joined table should be included in the JOIN predicate - IT (b.c2 = c.2 AND c.c3 = 'X').
Maybe you are looking for
-
Hard drive test failed on HP Pavilion dv6-1100eo laptop computer
I have a HP Pavilion dv6-1100eo Entertainment Notebook PC (P/N: NR597EA) with Vista 32 bit. Unfortunately no guarantees left in, and in general I was very satisfied with this laptop. But suddenly Wondows would not start up - and it has yet to start
-
Help! The radio works fine, when I try to play a MP3 song, the song appears in the display, pause/play button works, but when I hit the round central key I pass the diagonal lines low thte. (I downloaded the fileware this morning). avds, please... Th
-
Push app does not work: packaging / installation problem?
Hello I created a small Java application to manage the MDS (push RIM) push on my device. It is supposed to run as a module and launch on startup of the unit. It should create a new notification profile and listn for data push. Then it should display
-
Help for black login screen ThinkPad back?
Hey,. I have a T410 and recently installed some custom Windows 7 theme pack controller. I don't actually use the program, but when I uninstalled it, it took the login screen black of all my different themes with him. Is it possible to get it back? -G
-
Where's my other Creative Cloud App tabs?
Yesterday, something happened to my creative cloud application. I think that there is a new update of the app, but hope that I see is not permanent. The only tab I see now is the applications tab. A header for Adobe Stock was added to the upper part