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
I am stuck on a very simple SQL script. I want to do a LEFT JOIN on Google BigQuery.
SELECT a.name, b.name FROM [bigquery-00000:table1] a LEFT JOIN
[bigquery-00000:table2] b ON b.name = a.name LIMIT 10
And I keep getting an error message:
ON clause must be AND of = comparisons of one field name from each
table, with all field names prefixed with table name. Consider using
Standard SQL .google.com/bigquery/docs/reference/standard-sql/), which
allows non-equality JOINs and comparisons involving expressions and
residual predicates
I don't understand what is wrong with my script. Please help.
I found what was wrong with my script. Wrong table name... sorry.
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
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
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.
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