Table cannot be outer joined
hi
i have this query
SELECT xoj.entry_date job_date, xoj.well, xoj.rig, xoj.job_type,
xoj.job || xoj.job_type job_descritpion, xoj.opn_job_desc,
lab2.well_depth, fvl.attribute1, xoj.contract, xoj.invoice_date,
xoj.invoice_ref,
SUM (rad.amount) OVER (PARTITION BY xoj.opn_job_desc) invoice_amt,
SUM (npar_get_invoice_balance (ra.customer_trx_id, '31-Aug-2013')
) OVER (PARTITION BY xoj.opn_job_desc) pending_bal_due,
SUM (NVL (app.amount_applied, app.amount_applied_from)
) OVER (PARTITION BY xoj.invoice_ref) amount_paid_correct
FROM xxnp_opn_joblog_001 xoj,
napesco_well_stage_lab lab2,
fnd_flex_values_vl fvl,
ra_customer_trx_all ra,
ra_cust_trx_line_gl_dist_all rad,
ar_receivable_applications_all app,
ar_payment_schedules_all ps_inv,
ar_cash_receipts_all ar
WHERE xoj.opn_job_desc(+) = ra.attribute1
AND rad.customer_trx_id = ra.customer_trx_id
AND xoj.rig(+) = fvl.flex_value --this is the problem : a table cannot be outer joined to more than one
AND xoj.opn_job_id = lab2.job_id
AND xoj.invoice_ref = '2012-1575'
AND rad.account_class = 'REC'
AND rad.latest_rec_flag = 'Y'
AND app.applied_payment_schedule_id = ps_inv.payment_schedule_id
AND app.cash_receipt_id = ar.cash_receipt_id
AND app.display = 'Y'
AND ra.customer_trx_id = ps_inv.customer_trx_idi would like to include AND xoj.rig(+) = fvl.flex_value also in the query
kindly guide
thanking in advance
Edited by: makdutakdu on Apr 8, 2013 1:47 PM
Edited by: makdutakdu on Apr 8, 2013 1:48 PM
Sir ,i am not able to figure out why
SELECT *
FROM fnd_flex_values_vl fvl, xxnp_opn_joblog_001 xoj
WHERE
xoj.rig = fvl.flex_value
returns no value
whereas xoj.rig(+) =fvl.flex_value does return data ---as this returned data ,i would like to add it in my main query then again datatype of rig is char and flex_value is varchar2 .is tht the problem
and again xoj.rig=fvl.flex_value(+) does not return any datai know everyone in the forum is busy but i am just exploring new areas in oracle at my workplace with the tasks i am given ,which is why i post questions here when i am really stuck or ignorant
kindly guide
thanking in advance
Edited by: makdutakdu on Apr 8, 2013 3:24 PM
Similar Messages
-
OUTER JOIN -- Error: ORA-01417 (a table may be outer joined to at most one
Hi there,
I have a rather simple task: retrieve all the records in a table, for agiven domain p_domain_id (input parameter). The problem is that there are about 6 FKs in the table, and I need the names (strings) corresponding to those FKs (from other tables). Unfortunately, some of the FKs are NULL, so in '=' I loose records. Without the last 2 lines in WHERE clause, I get the correct result. With d2 in place (and without the "(+)" ) I loose 2 records. With the d3 (and also without "(+)"), I do not get any record.
With the "(+)", the code compiles but I get the run time error ORA-01417
NOTE: I put the "+" within parentheses, in order to show it like a text in this editor.
What's an elegant solution to this?
Thanks a lot.
Here's the code:
SELECT
a.DOMAIN,
b.NAME,
a.DE_ID,
a.NAME,
a.PREFERRED_LABEL,
a.TECHNICAL_DEFINITION,
a.PUBLIC_DEFINITION,
a.DE_TYPE,
c1.NAME,
a.HAS_PARAMETER,
a.VALUE_CLASS,
c2.NAME,
a.INDEX_TERMS,
a.DATA_TABLE_ID,
d1.TABLE_NAME,
a.SP_INSERT,
a.SP_UPDATE,
a.SP_GET_BYMRN,
a.SP_GET_BYATTRIBUTE,
a.VALUE_TABLE_ID,
d2.TABLE_NAME,
a.PARAM_TABLE_ID,
d3.TABLE_NAME,
a.PARAM_DOMAIN_LOGIC,
a.SP_LOV,
a.LOWER_LIMIT,
a.UPPER_LIMIT,
a.BOOLEAN_Y,
a.BOOLEAN_N,
a.COMMENTS,
a.ENTERED_BY,
commons_API.get_person_full_name(a.ENTERED_BY),
a.ENTERED_ON
FROM
DATA_ELEMENT_INDEX a,
DE_DOMAIN b,
GENERAL_LIST c1,
GENERAL_LIST c2,
TABLE_GROUP d1,
TABLE_GROUP d2,
TABLE_GROUP d3
WHERE
DOMAIN = p_domain_id AND
b.DOMAIN_ID = a.DOMAIN AND
c1.ID = a.DE_TYPE AND
c2.ID = a.VALUE_CLASS AND
d1.TABLE_ID = a.DATA_TABLE_ID AND -- it works well without the next two lines
d2.TABLE_ID = a.VALUE_TABLE_ID "(+)" AND
d3.TABLE_ID = a.PARAM_TABLE_ID "(+)"
ORDER BY a.NAME;
Edited by: user10817976 on Oct 19, 2009 8:14 AMOne of my standard replies...
Oracle syntax does not support outer joining to more than one table.
However ANSI syntax does...
SQL> select * from a;
ID B_KEY C_KEY
1 2 3
2 1 4
3 3 1
4 4 2
SQL> select * from b;
ID C_KEY2
1 1
2 5
3 3
4 2
SQL> select * from c;
KEY1 KEY2 DTA
1 1 1-1
1 2 1-2
1 3 1-3
1 4 1-4
2 1 2-1
2 2 2-2
2 3 2-3
2 4 2-4
3 1 3-1
3 2 3-2
3 3 3-3
3 4 3-4
4 1 4-1
4 2 4-2
4 3 4-3
4 4 4-4
16 rows selected.
SQL> ed
Wrote file afiedt.buf
1 select a.id as a_id, b.id as b_id, c.key1 as c_key1, c.key2 as c_key3, c.dta
2 from a, b, c
3 where a.b_key = b.id
4 and a.c_key = c.key1 (+)
5* and b.c_key2 = c.key2 (+)
SQL> /
and a.c_key = c.key1 (+)
ERROR at line 4:
ORA-01417: a table may be outer joined to at most one other table
SQL> ed
Wrote file afiedt.buf
1 select a.id as a_id, b.id as b_id, c.key1 as c_key1, c.key2 as c_key3, c.dta
2 from a JOIN b ON (a.b_key = b.id)
3* LEFT OUTER JOIN c ON (a.c_key = c.key1 and b.c_key2 = c.key2)
SQL> /
A_ID B_ID C_KEY1 C_KEY3 DTA
3 3 1 3 1-3
4 4 2 2 2-2
2 1 4 1 4-1
1 2
SQL> -
ORA-01417: a table may be outer joined to at most one other table
Hi All,
I want to display the data even if there is no corresposding data in the fac_pos table.
when using outer joins getting error message.
Any work around for this ? Please suggest. :-)
SQL> SELECT case when flen.FPID is not null then
2 'do the calculations here'
3 else
4 'no value in the FAC_POS table so do the ELSE PART'
5 end CASE ,
6 mtf.EXT_FID
7 FROM
8 D_F_MAP MTF,
9 FAC EFAC,
10 TRADING EST,
11 FAC_POS FLEN,
12 USERS_MAP custmap
13 WHERE mtf.SRC_FID = efac.FID (+)
14 AND mtf.SRC_DID = efac.DID (+)
15 AND efac.TFID = est.TFID
16 AND mtf.EXT_FID (+) = flen.FID
17 AND mtf.EXT_DID (+) = flen.DID
18 AND custmap.SRC_CUST_ID = est.SID (+)
19 AND custmap.EXT_CUST_ID = flen.CUSTID (+)
20 and est.TFID =14;
no rows selected
SQL> SELECT case when flen.FPID is not null then
2 'do the calculations here'
3 else
4 'no value in the FAC_POS table so do the ELSE PART'
5 end CASE ,
6 flen.CUSTID FROM TRADING EST, USERS_MAP,FAC_POS FLEN,FAC EFAC, D_F_MAP MTF
7 WHERE
8 EST.SID = USERS_MAP.SRC_CUST_ID (+) AND
9 USERS_MAP.EXT_CUST_ID = flen.CUSTID (+) AND
10 MTF.SRC_DID (+) = EFAC.DID AND
11 MTF.SRC_FID (+) = EFAC.FID AND
12 efac.TFID = est.TFID AND
13 mtf.EXT_FID (+) = flen.FID AND
14 mtf.EXT_DID (+) = flen.DID AND
15 est.TFID =14
16 /
MTF.SRC_FID (+) = EFAC.FID AND
ERROR at line 11:
ORA-01417: a table may be outer joined to at most one other table
create table D_F_MAP
SOURCE VARCHAR2(10) not null,
SRC_DID VARCHAR2(8) not null,
SRC_FID VARCHAR2(10) not null,
EXT_DID VARCHAR2(20),
EXT_FID VARCHAR2(20)
create table FAC
TFID NUMBER,
SRC VARCHAR2(10),
DID NUMBER,
FID NUMBER,
CSAMT NUMBER
create table FAC_POS
FPID NUMBER,
CUSTID NUMBER,
SRC VARCHAR2(10),
DID NUMBER,
FID NUMBER,
SPOS NUMBER
create table PASS_OVER
TFID VARCHAR2(20) not null,
FLG VARCHAR2(1)
create table TRADING
TFID NUMBER not null,
SRC VARCHAR2(10),
TDATE DATE,
BID NUMBER,
SID NUMBER
create table USERS_MAP
SRC_CUST_ID VARCHAR2(8) not null,
EXT_CUST_ID VARCHAR2(20),
SRC VARCHAR2(10) not null
insert into D_F_MAP (SOURCE, SRC_DID, SRC_FID, EXT_DID, EXT_FID)
values ('KP', '854', '7754', '101', '1202');
insert into D_F_MAP (SOURCE, SRC_DID, SRC_FID, EXT_DID, EXT_FID)
values ('KP', '4545', '4444', '504', '1604');
insert into D_F_MAP (SOURCE, SRC_DID, SRC_FID, EXT_DID, EXT_FID)
values ('KP', '7858', '9646', '604', '1705');
insert into D_F_MAP (SOURCE, SRC_DID, SRC_FID, EXT_DID, EXT_FID)
values ('MS', '8799', '4544', '987', '1654');
insert into FAC (TFID, SRC, DID, FID, CSAMT)
values (10, 'KP', 854, 7754, 85000);
insert into FAC (TFID, SRC, DID, FID, CSAMT)
values (11, 'KP', 854, 7754, 44000);
insert into FAC (TFID, SRC, DID, FID, CSAMT)
values (12, 'KP', 4545, 4444, 47000);
insert into FAC (TFID, SRC, DID, FID, CSAMT)
values (13, 'KP', 7858, 9646, 80000);
insert into FAC (TFID, SRC, DID, FID, CSAMT)
values (14, 'MS', 8799, 4544, 60000);
insert into FAC (TFID, SRC, DID, FID, CSAMT)
values (15, 'KP', 854, 7754, 66000);
insert into FAC_POS (FPID, CUSTID, SRC, DID, FID, SPOS)
values (94, 5555, 'EXT', 504, 1604, 6000);
insert into FAC_POS (FPID, CUSTID, SRC, DID, FID, SPOS)
values (90, 1111, 'EXT', 101, 1202, 1000);
insert into FAC_POS (FPID, CUSTID, SRC, DID, FID, SPOS)
values (91, 2222, 'EXT', 302, 3652, 1000);
insert into FAC_POS (FPID, CUSTID, SRC, DID, FID, SPOS)
values (92, 3333, 'EXT', 987, 1654, 6000);
insert into FAC_POS (FPID, CUSTID, SRC, DID, FID, SPOS)
values (93, 4444, 'EXT', 604, 1705, 9000);
insert into TRADING (TFID, SRC, TDATE, BID, SID)
values (10, 'KP', to_date('10-02-2009', 'dd-mm-yyyy'), 1548, 96751);
insert into TRADING (TFID, SRC, TDATE, BID, SID)
values (11, 'KP', to_date('02-02-2009', 'dd-mm-yyyy'), 5468, 7895);
insert into TRADING (TFID, SRC, TDATE, BID, SID)
values (12, 'KP', to_date('20-02-2009', 'dd-mm-yyyy'), 1258, 6985);
insert into TRADING (TFID, SRC, TDATE, BID, SID)
values (13, 'KP', to_date('22-02-2009', 'dd-mm-yyyy'), 5468, 7865);
insert into TRADING (TFID, SRC, TDATE, BID, SID)
values (14, 'MS', to_date('18-02-2009', 'dd-mm-yyyy'), 4669, 6893);
insert into TRADING (TFID, SRC, TDATE, BID, SID)
values (15, 'KP', to_date('20-02-2009', 'dd-mm-yyyy'), 1548, 6975);
insert into USERS_MAP (SRC_CUST_ID, EXT_CUST_ID, SRC)
values ('9675', '1111', 'kp');
insert into USERS_MAP (SRC_CUST_ID, EXT_CUST_ID, SRC)
values ('5468', '2222', 'kp');
insert into USERS_MAP (SRC_CUST_ID, EXT_CUST_ID, SRC)
values ('6893', '3333', 'kp');
insert into USERS_MAP (SRC_CUST_ID, EXT_CUST_ID, SRC)
values ('5468', '4444', 'kp');
insert into USERS_MAP (SRC_CUST_ID, EXT_CUST_ID, SRC)
values ('7865', '5555', 'kp');
insert into USERS_MAP (SRC_CUST_ID, EXT_CUST_ID, SRC)
values ('6975', '6666', 'kp');
insert into USERS_MAP (SRC_CUST_ID, EXT_CUST_ID, SRC)
values ('6975', '7777', 'kp');
insert into USERS_MAP (SRC_CUST_ID, EXT_CUST_ID, SRC)
values ('6985', '8888', 'kp');Thanks.Hi,
Thanks for posting the sample data in such a useful form! I'm sorry, I'm not at a database now, so I can't run it.
What are the correct results you want from that data?
You can outer-join to more than one table using ANSI notation.
Another solution is to do some of the joins in a sub-query. It looks like the problem is with the est table. If you join all the tables except est in a sub-query, then you can join est to that result set in the main query.
If you "want to display the data even if there is no corresponding data in the fac_pos table.", and fac_pos is being called flen, then you have the + signs in the wrong places.
16 AND mtf.EXT_FID (+) = flen.FID
17 AND mtf.EXT_DID (+) = flen.DID means "display data from flen even if there is no match in mtf". -
A table may be outer joined to at most one other table
I am trying to use a lookup dim (C) with inputs from 2 different lookup dim (A and B). And I getting the following error:
"a table may be outer joined to at most one other table"
Any suggestion?This is sql limitation that you can not have queries like
select ...
from a, b, c
where c.x1(+) = a.y
and c.x2(+) = b.z
Probaby you are genearting code similar to this. I will suggest to use Joiner instead of lookup as you have better control over join conditions there. Other option may be to use Transformation function. -
Can we join 3 tables with left outer join
hi friends.
Can any one tell how to join 3 tables using <b>left outer join</b>...i tried by taking some fields of <b>ekko,ekpo,eket</b>, but this not working ... plz give a sample code with some fields.Hi Uday
<b>Inner joins using 3 tables </b>
<i><b>Try this :-</b></i>
SELECT stpo~stlnr stpo~idnrk mast~matnr mara~mtart stpo~menge
INTO CORRESPONDING FIELDS OF TABLE zmat1 FROM mast
JOIN stpo ON stpo~stlnr = mast~stlnr
JOIN mara ON mara~matnr = mast~matnr
WHERE stpo~stlty = 'M' "AND stpo~idnrk IN s_matnr
AND mast~werks = 1000.
<b><i>Here s_matnr is a select-options on the selection-screen. </i></b>
<i><b>Or this. </b></i>
<b>Code: </b>
Select single Vbrk~Bukrs Vbrk~Kunrg Vbrk~Vbeln
Vbrk~Fkdat Vbrk~Bstnk_Vf Vbrk~Zterm
Tvzbt~Vtext
Vbak~Vbeln Vbak~Bstdk
Likp~Vbeln Likp~lfdat Likp~Lfuhr
into w_vbrk
from vbrk
inner join Tvzbt on Tvzbt~Zterm = Vbrk~Zterm and
Tvzbt~Spras = sy-langu
Inner join Vbfa as SalesLnk
on SalesLnk~vbeln = pu_vbeln and
SalesLnk~vbtyp_v = c_order
inner join Vbak on Vbak~Vbeln = SalesLnk~Vbelv
Inner join Vbfa as DeliveryLnk
on DeliveryLnk~vbeln = pu_vbeln and
DeliveryLnk~vbtyp_v = c_Delivery
inner join Likp on Likp~Vbeln = DeliveryLnk~Vbelv
where vbrk~vbeln = pu_Vbeln.
<i><b>This code locates sales, delivery and payment terms info from a billing document number.</b></i>
<i><b>or</b></i>
<b>
Here, this one also works fine :</b>
select zfpcd~cadivi zfpcd~proforma zfpcd~factura zfpcd~aniofactura
zfpcd~montousd zfpcd~montoap zfpcd~ebeln zfpcd~inco1
zfpcd~lifnr lfa1~name1 zcdvs~status zfpcd~conint
into it_lista
from zfpcd inner join zcdvs
on zfpcd~ebeln = zcdvs~ebeln
and zfpcd~proforma = zcdvs~proforma
and zfpcd~lifnr = zcdvs~lifnr
inner join lfa1
on zfpcd~lifnr = lfa1~lifnr
where zcdvs~status = '04'.
Reward if helpfull
Regards
Pavan -
Multiple tables using left outer join?
Hi, guys:
I have 4 tables: A, B, C; if I want to do the following:
A left outer join B, its result left outer join C.
How can I do that? BTW, I am using DB2.
The following is a sample inner join:
select a.id, b.first, c.last
from A as a, B as b, C as c
thanksselect ..
from A a
left outer join B b ON ....
left outer join C c ON ...
WHERE ...
rgds -
How to use left outer join on more than one table (source)
Hi all,
In our project we are converting the Unix shell & SQL scripts into OWB mappings. We are facing problem converting left outer join in OWB. here is one of the example. i have just pasted the FROM and where condition.
FROM ym_scr t1, branch_finmonth t3
LEFT OUTER JOIN item_image t2
ON (t1.branch_no = t2.branch_no
AND t1.item_no = t2.item_no
AND t3.to_date between t2.tran_dt and t2.to_dt
AND t2.to_dt >= '$start_images' ) <<<========= '$start_images' THIS COMES FROM THE UNIX VARAIBLE ,
We converts the same when we are putting it in OWB join Operator
INGRP1.branch_no = INGRP2.branch_no(+)
AND INGRP1.item_no = INGRP2.item_no(+)
AND INGRP3.to_date between t2.tran_dt and t2.to_dt
AND INGRP2.to_dt >= INGRP2.start_images
But as you see in the OWB opreator we can put left join with INGRP1 with INGRP2.
We can not make same join with INGRP3 & INGRP4 , becoz it failed saying "you cannot left outer join on more than one table/source".
so overall this OWB code makes incomplete left outer join as per the above ANSI SQL join in Oracle.
Bcoz of the problem we are getting less number of rows...........
SO please please help me on this
Regards
AshokHi.
I know this topic is here for a while now, but I had the same problem today, searched for help and didn´t find anything.
Later I figured out how to do this.
You just have to put the (+) one time, and the OWB converts in an LEFT OUTER JOIN statement.
For this case, all you have to do is:
( INGRP1.branch_no = INGRP2.branch_no(+) AND INGRP1.item_no = INGRP2.item_no AND INGRP2.to_dt >= INGRP2.start_images )
Regards,
Godoy -
Hi
Let's say I have three tables ORDERS, PRODUCT and CLIENT. I want a query that will give me all PRODUCT and CLIENT combinations and the total sum of orders if it has one. If I try to do this:
select P.NAME, C.NAME, SUM(O.AMOUNT)
from PRODUCT P, CLIENT C, ORDER O
where P.ID = O.PRODUCT_ID(+) and
C.ID = O.CLIENT_ID(+)
I get an error where I cannot double outer join a table.
Any ideas?3360 wrote:
BluShadow wrote:
and ANSI allows a little more in those terms than regular oracle syntax.It is different, but it cannot do anything that regular equi-joins cannot do. In most cases the optimizer converts ANSI joins to regular joins for execution, and this additional conversion has been subject to numerous bugs.ANSI does allow for doing things that regular Oracle syntax cannot do.
Here's an ANSI way to do it if you only want to see those client/product combinations that exist in orders table:
SQL> with product as (
2 select 101 id, 'Product 1' name from dual union all
3 select 102 id, 'Product 2' name from dual union all
4 select 103 id, 'Product 3' name from dual
5 ), client as (
6 select 11 id, 'Client 1' name from dual union all
7 select 12 id, 'Client 2' name from dual
8 ), orders as (
9 select 11 client_id, 101 product_id, 10 amount from dual union all
10 select 11 client_id, 103 product_id, 30 amount from dual union all
11 select 12 client_id, 102 product_id, 20 amount from dual union all
12 select 12 client_id, 102 product_id, 20 amount from dual
13 )
14 --
15 -- end-of-test-data
16 --
17 select p.name
18 , c.name
19 , sum(o.amount)
20 from orders o
21 left outer join product p
22 on p.id = o.product_id
23 left outer join client c
24 on c.id = o.client_id
25 group by
26 p.name
27 , c.name
28 order by
29 p.name
30 , c.name
31 /
NAME NAME SUM(O.AMOUNT)
Product 1 Client 1 10
Product 2 Client 2 40
Product 3 Client 1 30(If the datamodel is good with product_id being a foreign key of product.id and the same with client, then outer join is not really necessary, I know. But for the sake of argument assume bad datamodel that needs outer join ;-) )
The above ANSI can be written in regular Oracle syntax as well:
SQL> with product as (
2 select 101 id, 'Product 1' name from dual union all
3 select 102 id, 'Product 2' name from dual union all
4 select 103 id, 'Product 3' name from dual
5 ), client as (
6 select 11 id, 'Client 1' name from dual union all
7 select 12 id, 'Client 2' name from dual
8 ), orders as (
9 select 11 client_id, 101 product_id, 10 amount from dual union all
10 select 11 client_id, 103 product_id, 30 amount from dual union all
11 select 12 client_id, 102 product_id, 20 amount from dual union all
12 select 12 client_id, 102 product_id, 20 amount from dual
13 )
14 --
15 -- end-of-test-data
16 --
17 select p.name
18 , c.name
19 , sum(o.amount)
20 from orders o, product p, client c
21 where p.id(+) = o.product_id
22 and c.id(+) = o.client_id
23 group by
24 p.name
25 , c.name
26 order by
27 p.name
28 , c.name
29 /
NAME NAME SUM(O.AMOUNT)
Product 1 Client 1 10
Product 2 Client 2 40
Product 3 Client 1 30Many old Oracle coders will probably state that this syntax is much easier. For a simple case like this I find both ways easy. But I have complex cases where I much prefer ANSI where I can easily distinguish join predicates from filter predicates. It is a matter of opinion, I know ;-)
But if we then take the original post as a literal specification, that we want all combinations of products and clients and then the sum of order amount if it exists, null otherwise.
This can be written easily in ANSI notation:
SQL> with product as (
2 select 101 id, 'Product 1' name from dual union all
3 select 102 id, 'Product 2' name from dual union all
4 select 103 id, 'Product 3' name from dual
5 ), client as (
6 select 11 id, 'Client 1' name from dual union all
7 select 12 id, 'Client 2' name from dual
8 ), orders as (
9 select 11 client_id, 101 product_id, 10 amount from dual union all
10 select 11 client_id, 103 product_id, 30 amount from dual union all
11 select 12 client_id, 102 product_id, 20 amount from dual union all
12 select 12 client_id, 102 product_id, 20 amount from dual
13 )
14 --
15 -- end-of-test-data
16 --
17 select p.name
18 , c.name
19 , sum(o.amount)
20 from product p
21 cross join client c
22 left outer join orders o
23 on o.product_id = p.id
24 and o.client_id = c.id
25 group by
26 p.name
27 , c.name
28 order by
29 p.name
30 , c.name
31 /
NAME NAME SUM(O.AMOUNT)
Product 1 Client 1 10
Product 1 Client 2
Product 2 Client 1
Product 2 Client 2 40
Product 3 Client 1 30
Product 3 Client 2
6 rows selected.ANSI notation allows outer join with more than one table.
Regular Oracle syntax could only do this by creating an inline view of the cartesian join and then outer joining orders with the inline view. Doable, but not as nice (IMHO) as the ANSI method for a case like this ;-) -
Outer Join for 2 Tables?
Hi,
i have 3 Tables, one is the "main" table.
Table1
Col1
Col2
Col3
Table2
Col2
Col4
Col5
Table3
Col4
Col6
Now i want all hits from Table 1, all outer join hits from table 2 and the regarding rows from table 3.
The join from Table1 to Table2 is no problem, but how to add table3?
SELECT *
FROM table1 AS t1
LEFT OUTER JOIN table2 AS t2
ON t2col2 = t1col2
INTO CORRESPONDING FIELDS OF TABLE result
WHERE t1~col1 IN so_col1.Hi,
a right table in an outer join cannot become a part of an inner join or an outer join. So you will have to use some other technique.
meaing table1 connects to table2 with an outer join resulting in all rows table1 and cooresponding if existing from table2, now table2 is the right table it cannot make a join with table3. inner or outer.
regards,
Khusro Habib -
Best Practice - Outer Join between Fact and Dim table
Hi Gurus,
Need some advice on the below scenario
I have an OOTB subject area and we have around 50-60 reports based on it. The related subject area Fact and Dim1 table are having inner join.
Now I have a scenario for one report where outer join has to be implemented between Fact and Dim1. Here I am against changing the OOTB subject area join as the outer join will impact the performance of other 50-60 reports.
Can anyone provide any inputs on what is the best way to handle this scenario?
ThanksOk. I tried this:
Driving table : Fact, Left outer join -- didnt work.
Driving table: Dimension D left outer join -- didnt work either
In either the case, I see physical query as D left outer Join on Fact F. and omitting the rows.
And then I tried this -
Driving table: Fact, RIght outer join.
Now, this is giving me error:
Sybase][ODBC Driver]Internal Error. [nQSError: 16001] ODBC error state: 00000 code: 30128 message: [Sybase][ODBC Driver]Data overflow. Increase specified column size or buffer size. [nQSError: 16011] ODBC error occurred while executing SQLExtendedFetch to retrieve the results of a SQL statement. (HY000)
I checked all columns, everything matched with database table type and size.
I am pulling Fact.account number, Dimension.account name, Fact.Measures. I am seeing this error each time I pull Fact.Account number. -
Maximum number of tables that can be outer joined with one table in a query
Hi All,
Iam new to sql, so can you please let me know What is the maximum number of tables that can be outer joined with one table in a query?
Thanks,
Srinisrinu2 wrote:
Iam new to sql, so can you please let me know What is the maximum number of tables that can be outer joined with one table in a query?
There is no limit to the number of tables you can outer join as long as you join them correctly.
SQL> with a as
2 (
3 select 1 id, 2 b_key, 3 c_key from dual union all
4 select 2 id, 1 b_key, 4 c_key from dual union all
5 select 3 id, 3 b_key, 1 c_key from dual union all
6 select 4 id, 4 b_key, 2 c_key from dual
7 ),
8 b as
9 (
10 select 1 id, 1 c_key2 from dual union all
11 select 2 id, 5 c_key2 from dual union all
12 select 3 id, 3 c_key2 from dual union all
13 select 4 id, 2 c_key2 from dual
14 ),
15 c as
16 (
17 select 1 key1, 1 key2, '1-1' dta from dual union all
18 select 1 key1, 2 key2, '1-2' dta from dual union all
19 select 1 key1, 3 key2, '1-3' dta from dual union all
20 select 1 key1, 4 key2, '1-4' dta from dual union all
21 select 2 key1, 1 key2, '2-1' dta from dual union all
22 select 2 key1, 2 key2, '2-2' dta from dual union all
23 select 2 key1, 3 key2, '2-3' dta from dual union all
24 select 2 key1, 4 key2, '2-4' dta from dual union all
25 select 3 key1, 1 key2, '3-1' dta from dual union all
26 select 3 key1, 2 key2, '3-2' dta from dual union all
27 select 3 key1, 3 key2, '3-3' dta from dual union all
28 select 3 key1, 4 key2, '3-4' dta from dual union all
29 select 4 key1, 1 key2, '4-1' dta from dual union all
30 select 4 key1, 2 key2, '4-2' dta from dual union all
31 select 4 key1, 3 key2, '4-3' dta from dual union all
32 select 4 key1, 4 key2, '4-4' dta from dual
33 )
34 select d.a_id, d.b_id, c.key1 as c_key1, c.key2 as c_key3, c.dta
35 from
36 c,
37 (
38 select
39 a.id as a_id, b.id as b_id, a.c_key, b.c_key2
40 from a, b
41 where a.b_key = b.id
42 ) d
43 where d.c_key = c.key1 (+)
44 and d.c_key2 = c.key2 (+);
A_ID B_ID C_KEY1 C_KEY3 DTA
3 3 1 3 1-3
4 4 2 2 2-2
2 1 4 1 4-1
1 2
SQL> -
How to use outer join on 2 tables with Oracle 8i
Could anyone tell me the Oracle 8i syntax equivalent to :
select user.name, city.adress, contry.name
from user
left outer join city on (user.rCity = city.code)
left outer join country on (user.rCountry = country.code)
I tried following :
select user.name, city.adress, contry.name
from user, city, contry
where user.rCity (+) = city.code
and user.rCountry (+) = country.code
but displayed following error :
ORA-01417: a table may be outer joined to at most one other table
Thank youLogically I would expect a user to have a city and a country, or not. In that case the outer join should be on the other tables. Making your query:
select user.name, city.adress, country.name
from user, city, country
where user.rCity = city.code (+)
and user.rCountry = country.code (+); -
Oracle outer join on multiple tables throws error
Hi ,
We are using ansi joins with outer joins on multiple tables in oracle 9i.
Now these queries have to be used in Oracle8i.
Since Oracle8i does not support ansi sql we are replacing the ansi sql queries with the oracle joins.
On trying the same we found that the following query
select *from tab1 a, tab2 b, tab3 c where a.c1 = b.col1(+) and c.c2 = b.col2 (+)
throws the error
ORA-01417: a table may be outer joined to at most one other table.
Is there a way to simulate this query without using the outer joins on multiple tables?
thanksTry writing the query in this form:
select * from
(select t1.col1, t1.col2
from schema.table1 t1, schema.table2 t2
where t1.col1 = t2.col1(+)) t4,
schema.table3 t3 where t4.col2 = t3.col2(+)
In the subquery, you will have to list all the columns you want to see, and you will need to provide unique aliases for any columns with duplicate names. I tested this on 9i, and don't have an 8i system to work with, so I hope this helps. -
Left outer join on Fact and dimension table.
Hi all, I have a fact F with account number and few measures as columns.
I also have a dimension D with account number, account name columns.
Few account numbers from Fact doesnt exist in Dimension D , but they need to show up in the report though.
How do I left join Fact and Dimension D in RPD?
I have this report where I need to show Account Number, Account name, measures.
If D doesnt have certain account numbers, I need to convert that account number from F as string and show it in the report in account name column.
Can you pls help.Ok. I tried this:
Driving table : Fact, Left outer join -- didnt work.
Driving table: Dimension D left outer join -- didnt work either
In either the case, I see physical query as D left outer Join on Fact F. and omitting the rows.
And then I tried this -
Driving table: Fact, RIght outer join.
Now, this is giving me error:
Sybase][ODBC Driver]Internal Error. [nQSError: 16001] ODBC error state: 00000 code: 30128 message: [Sybase][ODBC Driver]Data overflow. Increase specified column size or buffer size. [nQSError: 16011] ODBC error occurred while executing SQLExtendedFetch to retrieve the results of a SQL statement. (HY000)
I checked all columns, everything matched with database table type and size.
I am pulling Fact.account number, Dimension.account name, Fact.Measures. I am seeing this error each time I pull Fact.Account number. -
Left Outer Joining multiple tables to one source table FAILS with VLD-1511
Hi all,
Is it me, or is OWB unable to handle left outer joining 1 source table to multiple other tables?
I want to load a fact table so I have 1 source table with measures. This table must be outer joined to some dimensions that have their FK in the fact table.
The SQL statement would look like this (and is perfectly valid):
select ...
from input, dim1, dim2
where input.c1 = dim1.c1(+)
and input.c2 = dim2.c2(+);
I put the where clause in the joiner operator and validate, but that gives me message VLD-1511: A table may be outer joined to at most one other table.
Even splitting this up into one outer join per joiner still gives this message.
A search and look around on the forum and on metalink shows there are related issues (like bug 3334035). Seemingly creating a view is the work-around to use.....? (ie downgrading owb to a simple gui tool) }-;
Have other people experienced this problem of not being able to outer join one input table to multiple other tables?
Thanks,
EdI have had some feedback from Oracle. It turns out this has to do with 2 issues. Below I have pasted the text that Support gave me:
<---------- START QUOTE ---------->
RESEARCH
=========
Bug 3437036 KEY LOOKUP DOES NOT DETECT ORA-1417 IN VALIDATE/GENERATE STEP
Unpublished Bug 4211684 FORWARD PORT OF BUG 3437036
shows:
Some more development has been completed when this bug is fixed in Paris.
The following are the details:
1. If the join condition contains a full outer join such as
tab1.c (+) = tab2.c (+) and tab2.c (+) = tab3.c
then the new validations implemented for this bug do not apply since
in OWB, full outer join triggers generation of joins in ANSI syntax.
ANSI syntax does not have the original problem the base bug of this
bug reported.
2. If the join condition does not contain any full outer join condition,
then the join is generated in Oracle join syntax, which is subject two
several restrictions. The fix to this bug check two of the restrictions.
3. The first restriction in Oracle syntax is that the outer join operator
"(+)" can only directly be attached to a column name. If you attach it
to an expression, such as the following:
(tab1.c + 1) (+) = tab2.c
Then there will be an ORA-936 error at the time of mapping deployment.
For this case, I have added a validation message VLD-1512 to error out
this situation.
4. The second restriction in Oracle syntax is that a table can only be
outer joined to exactly one other table.
For example, this is an invalid join in Oracle syntax:
tab1.c (+) = tab2.c and tab1.d (+) = tab3.d
because tab1 is left outer joined to tab2 and tab3.
But note that the following is still valid in Oracle syntax:
tab1.c (+) = tab2.c and tab1.d = tab3.d (+)
because tab1 is left outer joined to tab2 and right outer joined to tab3.
So this latter case does not violate the restriction that "same oj" to
more than 1 table is not allowed.
If same oj to more than 1 table is specified in a join condition,
VLD-1511 will be issued, and the map is made invalid.
<---------- END QUOTE ---------->
OWB does a partial validation, ie not all access paths are (can be) checked. A full check is only done by the database itself. So some scenarios (like checking whether multiple tables are outer joined the correct way) are not checked, and in this case are flagged with an error (even though it is actually a correct scenario).
Seemingly this was not flagged with an error in earlier versions of OWB, so beware, OWB behaviour may change when upgrading...
Alternative solutions are (1) using key lookups, (2) using a view with all outer joins in there, (3) using intermediate result tables between the joins.
Hope this info helps some people prevent spending too much time on a false error message,
Ed
Maybe you are looking for
-
Kensington USB 3 Super Speed Dock not functioning
I have a Kensington USB 3.0 Super Speed Dock connected via a USB cable to my 13" macbook air (purchased in January 2014). Mid2013, 1.7 GHZ. Intel core i7. 8 GB 1600 MHz DDR3. Intel HD Graphics 5000 1536 MB Since upgrade to Yosemite the dock is not re
-
When I click on FrameMaker it will not launch. It appears in the "Process" section of Task Manager, but will not load to the screen. Is anyone aware of what might be causing this?
-
Need some information confirmed about the content ID number
Is it possible to have it change the auto number prefix in a contextual manner. example default:xxxx001 doc-a:xxxy00[1|2] doc-b:xxxz00[1|3]
-
Hi friends, normally how many queries are stored in a workbook.
-
Hi, I had a cluster distributed on three nodes: server09 (node1), server08(node2) and server07(node3). I deleted erroneously many system files from server08 and now I need to start the cluster on the other nodes. I started the server09 and server07 b