Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Update set of records in Oracle

Posted on 2014-03-03
1
Medium Priority
?
443 Views
Last Modified: 2014-03-10
I need to update a set of records in Oracle but to do so I need to join two tables to get the exact records that I need to update.  I am trying this statement but getting a non-preserved key error.

I have attached the update statement (note the tables and field names are changed to keep information confidential)update-records.txt
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
1 Comment
 
LVL 74

Accepted Solution

by:
sdstuber earned 2000 total points
ID: 39902284
UPDATE employee ep
   SET reported_name = 'XYZ'
 WHERE ep.state LIKE 'ACME'
   AND table_name LIKE 'EMPLOYEE'
   AND ep.county LIKE 'ACME'
   AND EXISTS
           (SELECT NULL
              FROM versions v
             WHERE ep.name = v.name AND ep.version = v.version);


"table_name" wasn't aliased so I don't know if it was from employee or versions.
Simply move that condition to the EXISTS subquery if it applies to versions.

Also,  your "LIKE" conditions don't have wildcards.  So those should probably be equalities instead.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
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…

609 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