Кажется, вы попали в ORA-01417.Используя составленные таблицы и данные, которые вы не предоставили, или условия соединения, я могу получить тот же эффект, пытаясь выполнить внешнее соединение monkey
с tree
и banana
- полностью надуманным способом,курс:
with banana as (select 'yellow' as colour, 1 as template_id, null as enddate
from dual),
monkey as (select 'capuchin' as monkeytype, 1 as template_id, null as enddate
from dual),
tree as (select 'tropical' as treetype, 1 as template_id from dual)
select t.treetype, b.colour, m.monkeytype
from tree t, banana b, monkey m
where t.template_id = 1
and b.template_id (+) = t.template_id
and b.enddate (+) is null
and m.template_id (+) = t.template_id
and m.enddate (+) is null
and m.template_id (+) = b.template_id;
Error at Command Line:10 Column:22
Error report:
SQL Error: ORA-01417: a table may be outer joined to at most one other table
01417. 00000 - "a table may be outer joined to at most one other table"
*Cause: a.b (+) = b.b and a.c (+) = c.c is not allowed
*Action: Check that this is really what you want, then join b and c first
in a view.
если вы используете «новый» (начиная с 9i, я думаю) синтаксис объединения ANSI, а не специфическую для Oracle нотацию (+)
, вы можете сделать больше:
with banana as (select 'yellow' as colour, 1 as template_id, null as enddate
from dual),
monkey as (select 'capuchin' as monkeytype, 1 as template_id, null as enddate
from dual),
tree as (select 'tropical' as treetype, 1 as template_id from dual)
select t.treetype, b.colour, m.monkeytype
from tree t
left join banana b on b.template_id = t.template_id
and b.enddate is null
left join monkey m on m.template_id = t.template_id
and m.enddate is null
and m.template_id = b.template_id
where t.template_id = 1;
TREETYPE COLOUR MONKEYTYPE
-------- ------ ----------
tropical yellow capuchin
См. документацию для ознакомления с некоторыми ограничениями на (+)
;Oracle рекомендует использовать версию ANSI, хотя они, похоже, большую часть времени используют свои собственные примеры в документации.