" (+) = " operator in oracle sql in where clause - sql

while changing stored procedure i came across (+) = operator. I have read Oracle "(+)" Operator but seems like my problem is slightly different than one mentioned in that link.
So, can anyone please help me understand statement like:
select ....
from emp, dept
where emp.dept_id (+) = dept.dept_id
why would they use both + and = sign while using this condition? I would be thankful if someone will help me with example or link where i can read about such operators.

The (+)= operator refers to Oracle outer Joins wich simply extends the functionality of simple joins.
See the following link on this operator and this link on how to use it with example

This is the deprecated notation of a LEFT OUTER JOIN.
The new and preferred notation according to the ANSI standard is:
select ....
from emp
left outer join dept
on emp.dept_id = dept.dept_id

Related

What does this Operator in SAP ABAP means "(+)=" [duplicate]

while changing stored procedure i came across (+) = operator. I have read Oracle "(+)" Operator but seems like my problem is slightly different than one mentioned in that link.
So, can anyone please help me understand statement like:
select ....
from emp, dept
where emp.dept_id (+) = dept.dept_id
why would they use both + and = sign while using this condition? I would be thankful if someone will help me with example or link where i can read about such operators.
The (+)= operator refers to Oracle outer Joins wich simply extends the functionality of simple joins.
See the following link on this operator and this link on how to use it with example
This is the deprecated notation of a LEFT OUTER JOIN.
The new and preferred notation according to the ANSI standard is:
select ....
from emp
left outer join dept
on emp.dept_id = dept.dept_id

Oracle left join sql query issue

I have one SQL query in which they have used Left-Join feature and now there is a requirement to convert it into operator (+) syntax. Please guide me how to do it, The query is as written below :
select (some field names)
from
ldcs2.component comp
LEFT JOIN ldcs2.component_detail cd
ON cd.component_id = comp.component_id
LEFT JOIN ldcs2.component_item_breakdown cib
ON cib.component_item_id = cd.component_item_id
So please guide me what does Left-Join specify here and how can we write it into (+) expression.
Also guide me as they have mentioned second mapping table (ldcs2.component_detail) at first in ON condition, whether it would work differently if we write at first in that condition or not?
This is what you could do, but I have to note that personally I prefer the ANSI way.
There are two sides of a join condition. When you use ANSI syntax and code A left join B, you imply that for a record in A, there is no need to be a match on B.
When you put (+) on a specific side of the join condition you imply something like "The field on this side of the condition need not to be matched."
select (some field names)
from
ldcs2.component comp,
ldcs2.component_detail cd,
ldcs2.component_item_breakdown cib
where
cd.component_id (+) = comp.component_id
and cib.component_item_id (+) = cd.component_item_id
You could convert the ANSI/ISO Syntax to Oracle outer join syntax as follows -
SELECT (SOME field names)
FROM ldcs2.component comp,
ldcs2.component_detail cd,
ldcs2.component_item_breakdown cib
WHERE comp.component_id = cd.component_id(+)
AND cd.component_item_id = cib.component_item_id(+)
/
So please guide me what does Left-Join specify here and how can we write it into (+) expression.
For a detailed understanding, see my previous answer on a similar question here https://stackoverflow.com/a/28499208/3989608

(+) symbol in SQL Query

Just i have came across a SQL query in one of the stored procedure like below:
SELECT
*
FROM
account a,
performance p,
customer c,
override o
WHERE
a.account_id = p.account_id (+)
AND a.account_id = c.account_id (+)
AND o.override_type(+) = 'O'
Can you please explain what is the (+) symbol's play here? and the difference of using Left side and right side.
Thanks in advance.
It is the old syntax for OUTER JOIN in Oracle (I don't know whether there are other RDBMS that uses the same old syntax or not).
Better off: Use the explicit ANSI-92 OUTER JOIN syntax using LEFT OUTER JOIN or RIGHT OUTER JOIN instead of the + symbol.
(+) is an legacy outer join syntax in oracle (8 and before). It is very restrictive and handles many cases just wrong. Don't use it anymore. Oracle supports ansi joins (eg. left outer join) since version 9.

extractValue and right outer join - Oracle SQL

i got a little (at least i hope so) problem with an SQL Query. Here's my join
WHERE obj.mod_type = 'SER'
and obj.wrk_id=wrk_lang.id(+)
and extractvalue(value(shm),'/*/#xmi:id','xmlns:xmi="http://www.omg.org/XMI"') = extractvalue(value(shm_con),'/*/#source')(+)
It gives me an "ORA-00936: missing expression"
When i remove the second outer join it works fine(also with a regular join).
Can smb. help me?
It looks to me like this is actually a LEFT outer join - in old-style Oracle syntax the (+) is put on the optional side of the join while in ANSI syntax the required side (LEFT or RIGHT) is called out in the JOIN specification - see this AskTom reference for examples. So, expanding on #FlorinGhita's recommendation to use ANSI JOIN syntax (and making a bit of an assumption about the rest of the statement) we'd get something like
SELECT *
FROM OBJ
LEFT OUTER JOIN WRK_LANG
ON (obj.wrk_id = wrk_lang.id and
extractvalue(value(obj.shm),'/*/#xmi:id','xmlns:xmi="http://www.omg.org/XMI"') =
extractvalue(value(wrk_lang.shm_con),'/*/#source')
WHERE obj.mod_type = 'SER';
Share and enjoy.

What does (+) do in Oracle SQL?

I'm using Oracle SQL Developer to query an Oracle DB (not sure which version it is) and I'm going to use the SQL I make for a Crystal report. Many of the reports the previous developers have written don't use JOIN keywords to make the joins (and I'm not too familiar with JOIN keywords as a result).
Many of the joins they make are made in the WHERE statement. I'll notice something like this.
Select * From TableA, TableB WHERE TableA.PrimaryKey(+) = TableB.ForeignKey
My question is concerning the (+). What purpose does it serve and how do I use it in my code?
It is not recommended. See this previous answer
Difference between Oracle's plus (+) notation and ansi JOIN notation?
That represents a “right outer join” (right because the = is on the right side of the +).
SELECT *
FROM TableA, TableB
WHERE TableA.PrimaryKey(+) = TableB.ForeignKey
is equivalent to
SELECT *
FROM TableA
RIGHT OUTER JOIN TableB
ON (TableA.PrimaryKey = TableB.ForeignKey)
right outer join
(+) is used to perform right outer join in Oracle
RIGHT OUTER JOIN is one of the JOIN operations that allow you to specify a JOIN clause
For details
http://docs.oracle.com/javadb/10.8.3.0/ref/rrefsqlj57522.html