Solved

Update Query returine more then one row in Oracle

Posted on 2014-04-21
4
385 Views
Last Modified: 2014-04-25
I need update all values on one table as T where there exist certain condition on other table.

I know this query is wrong but how do I get it to work in Oracle update statement if the select statement between () returns a value

update sample s set s.L_INVOICE_FLAG  = 'T' where (s.project like (select p.name from project p inner join sample s on p.name = s.project where p.closed = 'T' and p.status = 'V'))
0
Comment
Question by:gilnari
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 40013720
Not sure I follow the logic but try IN.

Change:
...  where (s.project like (select p.name ...
to:
...  where (s.project in (select p.name ...
0
 
LVL 49

Expert Comment

by:PortletPaul
ID: 40013987
and then also remove the inner join as it won't be required
UPDATE sample s
SET s.L_INVOICE_FLAG = 'T'
WHERE s.project IN (
		SELECT p.NAME
		FROM project p
		WHERE p.closed = 'T' AND p.STATUS = 'V'
		)

Open in new window

0
 

Expert Comment

by:sunnyboyxjx
ID: 40014273
... where (s.project like ...
and
... on p.name = s.project  ...
are duplicated.
So it should be like this:
update sample s set s.L_INVOICE_FLAG  = 'T' where s.project in (select p.name from project p where p.closed = 'T' and p.status = 'V')
you can not use 'like' against sub-query.
0
 
LVL 49

Expert Comment

by:PortletPaul
ID: 40014920
@sunnyboyxjx
did I not propose exactly the same query?
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
Suggested Courses

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question