473,545 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Update through join

3 New Member
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 17910
chandu031
78 Recognized Expert New Member
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
Melancolie
3 New Member
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 Recognized Expert Expert
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(hardwar e) also.
May 3 '07 #4
Melancolie
3 New Member
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(hardwar e) 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
2459
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 Table PhotoID FileName 1 111.jpg
17
4976
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 = b.ded_type_cd and a.chk_no = b.chk_no group by cust_no, ded_type_cd, chk_no)
2
2507
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 to wrong records and I need to fix them using an Update statement. I have a sample code to reproduce my problem. To simplify the scenario I am trying to use Order related tables to explain a...
9
2916
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 ------------------ ----- ----- 21:09:13.310 0 0 0 21:09:19.370 9000 NULL NULL 21:09:21.310 NULL 95 NULL 21:10:12.380 9000 NULL NULL 21:10:24.310 NULL 253 NULL
4
2238
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: declare @IDate smalldatetime select @IDate=col001 from USDay select * from USDay A
2
8511
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 in a field produced by a query result? An example of what I'm trying to do is below: update (tbl_ind_mananas LEFT JOIN (select count(*) as count, (dubicacion || zona || manzana) as cod_manzana...
4
11320
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 it might look like this: UPDATE tblAddress SET AddressDescription of Entity 456 = AddressDescription of Entity_ID 123 Address1 of Entity 456 = Address1 of Entity_ID 123 City of Entity 456 =...
2
2602
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 with batch ID of 5 and I wanted to update both of them with their price, based on the data in the from clause. One row has 105 units and the other row has 2006 units. the active price in both rows is...
0
2748
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 below CREATE PROCEDURE <Procedure_Name, sysname, ProcedureName> -- Add the parameters for the stored procedure here <@Param1, sysname, @p1> <Datatype_For_Param1, , int> = <Default_Value_For_Param1,...
3
3938
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 new value for ABC. update T set ABC=? where ID = ?
0
7475
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7409
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7921
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7437
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5982
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4958
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3465
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1900
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.