Go Premium for a chance to win a PS4. Enter to Win


Update Query returine more then one row in Oracle

Posted on 2014-04-21
Medium Priority
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'))
Question by:gilnari
  • 2
LVL 78

Accepted Solution

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

...  where (s.project like (select p.name ...
...  where (s.project in (select p.name ...
LVL 49

Expert Comment

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

Open in new window


Expert Comment

ID: 40014273
... where (s.project like ...
... 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.
LVL 49

Expert Comment

ID: 40014920
did I not propose exactly the same query?

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

971 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