472,333 Members | 1,137 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,333 software developers and data experts.

Update through join

Hey! I'm kinda new to oracle. I usually solve problems fast, but cant get this one.

I got 2 tables:

Test_data which has columns:
Test_navn
Test_pakke

Test_def which has columns:
Test_navn
Pakke

Test_data.test_pakke is unpopulated, and i want to populate it with Test_def.pakke where Test_navn of the 2 tables match.


From my MySQL days, i used this:

Expand|Select|Wrap|Line Numbers
  1. update test_data as tda, test_def as tde
  2. set test_pakke = tde.pakke
  3. where tda.test_navn = tde.test_navn
But i get a "ORA-00971: missing SET keyword" error... I get that no matter how i construct it.

The tables holds thousands of records, so i hope to get this working.. So hope you can help.
May 2 '07 #1
4 17801
chandu031
78 Expert
Hey! I'm kinda new to oracle. I usually solve problems fast, but cant get this one.

I got 2 tables:

Test_data which has columns:
Test_navn
Test_pakke

Test_def which has columns:
Test_navn
Pakke

Test_data.test_pakke is unpopulated, and i want to populate it with Test_def.pakke where Test_navn of the 2 tables match.


From my MySQL days, i used this:

Expand|Select|Wrap|Line Numbers
  1. update test_data as tda, test_def as tde
  2. set test_pakke = tde.pakke
  3. where tda.test_navn = tde.test_navn
But i get a "ORA-00971: missing SET keyword" error... I get that no matter how i construct it.

The tables holds thousands of records, so i hope to get this working.. So hope you can help.

Hi,

In oracle there is no update join as in MySQL where you can update two tables in a single statement. A workaround would be to use corelated query.
Your query should look something like this:

UPDATE TEST_DATA A
SET TEST_PAKKE = (SELECT PAKKE FROM TEST_DEF B WHERE A.TEST_NAVN = B.TEST_NAVN)

This should do the trick, although it will perform slowly when there are a very large number of records.
May 2 '07 #2
Thanks Chandu :)

However i found the solution just 2 minutes after i posted...

Almost similiar to yours..

update test_data a
set test_pakke = (select distinct pakke from test_def b where a.test_navn = b.test_navn)


Only took a few mins for 13421 records :)
May 2 '07 #3
debasisdas
8,127 Expert 4TB
He said it will perform slowly because performance wise Corelated sub-queries are slowest.

Because while normal sub-query is evaluated only once for the table a
co-related sub-query is evaluated once per each row in the table

Again it depends on some other physical factors(hardware) also.
May 3 '07 #4
He said it will perform slowly because performance wise Corelated sub-queries are slowest.

Because while normal sub-query is evaluated only once for the table a
co-related sub-query is evaluated once per each row in the table

Again it depends on some other physical factors(hardware) also.
Thats correct :) But it was a one time update to expand a table and drop another one, so performance wasnt an issue..
May 3 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Narine | last post by:
Hi All, I need to write one complicated update statement and I'm looking at maybe finding a simpler way to do it. I have 2 tables: 1.Photo...
17
by: kalamos | last post by:
This statement fails update ded_temp a set a.balance = (select sum(b.ln_amt) from ded_temp b where a.cust_no = b.cust_no and a.ded_type_cd =...
2
by: serge | last post by:
/* This is a long post. You can paste the whole message in the SQL Query Analyzer. I have a scenario where there are records with values pointing...
9
by: Vorpal | last post by:
Here is a small sample of data from a table of about 500 rows (Using MSSqlserver 2000) EntryTime Speed Gross Net ------------------ -----...
4
by: 001 | last post by:
Hello, The select statement needs only 1 second to complete the query. But the update statement spends 30 minutes. Why? SELECT STATEMENT:...
2
by: Mike Leahy | last post by:
Hello all, This question is related to updating tables - is there any way to calculate or update the values in a column in a table to the values...
4
by: deko | last post by:
I'm trying to update the address record of an existing record in my mdb with values from another existing record in the same table. In pseudo code...
2
by: Sim Zacks | last post by:
The following query updated all the rows in the AssembliesBatch table, not just where batchID=5. There are 2 rows in the AssembliesBatch table...
0
by: svgeorge | last post by:
I want to update several tables using one stored procedure. How can i do this I mean the syntax.etc. declaration etc. I know the basic syntax as...
3
by: Michel Esber | last post by:
Hi all, DB2 V8 LUW FP 15 There is a table T (ID varchar (24), ABC timestamp). ID is PK. Our application needs to frequently update T with a...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.