Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL problem

Status
Not open for further replies.

WP

Programmer
Nov 30, 1999
463
CH
In my Oracle database I have two tables

Table A Table B
EXCHANGE <------------> EXCHANGE
ISIN<----------------------> ISIN
SEDOL<-------------------> SEDOL
RISK RISK
etc. etc.

which share EXCHANGE,ISIN and SEDOL as there key and are matched 1 to 1.

How do I update table A RISK with table B RISK ?


Bill Paton
william.paton@ubsw.com

Check out
 
update tablea
set risk = (select risk from table b where tableb.exchange = tablea.exchange and tableb.isin = tablea.isin and tableb.sedol = tablea.sedol)
 
If your tables are exactly the same you could try:

insert into table A
select * from table B;
 
I'd not read your question properly, why do you appear to have two identical tables?
 
They are not the same and I have just found that there is a one to many relationship from A to B. The two tables are not the same the only fields that are the same are those I listed.

We have an extract that currently loads into A. A new table B is going to replace it. Until the code is written for the new extract I need a workaround.

I need to have a SP that reads A and updates B. Bill Paton
william.paton@ubsw.com

Check out
 
My last posting should do it (Just revese the table ref as the orig copies from B to A. Performance could be a problem though if there are many rows.

As 1 row in A relates to many rows in B you will be updating several rows in B with 1 row of info from A. Is this what you want?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top