Topic: SQL*Plus and PL/SQL >> Usage of "where exists" clause
|
Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property.
You may review the entire Oracle Certification Program Candidate Agreement online Here.
|
|
|
|
| Title: Usage of "where exists" clause |
| Nash |
Posted: Aug 30, 2008 11:45:21 PM |
Total Post: 1
Joined: Aug, 2008
|
Consider tables A and B. Both the tables have columns x,y and z. Column x of A is updated with column x of B based on the equality condition, A.y=B.y and A.z= B.z.
May I know the difference between the update statements given below?
i) update B
set x=( Select x
from A
where A.y=B.y
and A.z=B.z)
ii) update B
set x=( Select x
from A
where A.y=B.y
and A.z=B.z)
where exists(Select y,z
from A
where A.y=B.y
and A.z=B.z) |
|
|
6s |
| Posted: Sep 01, 2008 04:34:24 AM | |
|
Total Post: 1
Joined: Sep, 2008
|
If the subquery returns at least one row, then only the entire update will work (atleast updation of one row will happen).
So whenever EXISTS is used and your DML task is done, be sure the subquery condition has been met.
You can use NOT EXISTS as well.
|
|
|
|
|
| Time Zone: EDT |
Send this thread to your friend |
|
|
|
|
Forum Rules & Description
Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user
|
| |
Get FREE Magazines
|
Top 10 Forum User
|
| Murtuja Khokhar | 857 |
| Mohammed Taj | 746 |
| positive fanatic | 483 |
| Jayanta Sur | 479 |
| Vigyan Kaushik | 386 |
| Vinoth Kumar | 357 |
| Gopu Gopi | 340 |
| Gitesh Trivedi | 322 |
| neeraj sharma | 258 |
| Ramesh Jois | 246 |
|
|