Home » SQL & PL/SQL » SQL & PL/SQL » updating table 2 (Oracle 10g)
updating table 2 [message #409272] Sun, 21 June 2009 13:40 Go to next message
sninii@yahoo.com
Messages: 2
Registered: May 2009
Junior Member
Hello All

I have tow tables Table1 and Table2 respectively with the following values
create table table1(code number(6), type varchar2(30));

insert into table1 values(454356,'ZXFC');
insert into table1 values(568678,'ACRX');
insert into table1 values(678687,'MERX');

create table table2(designation varchar2(200),code number(6), type varchar2(30));

insert into table2 values('Manager,ZXFC,West Zone','','');
insert into table2 values('Divisional incharge, ACRX, East','','');
insert into table2 values('DSM North, MERX, North East','','');

I need to update CODE and TYPE in table2 by traversing the DESIGNATION i.e. the DESIGNATION in table2 will have TYPE and there by getting the corresponding TYPE and CODE values from table1 and updating table2

The end result should be
TABLE2
________
DESIGNATION             CODE        TYPE
Manager,ZXFC,West Zone	454356	    ZXFC
Manager,ZXFC,West Zone	568678	    ACRX
Manager,ZXFC,West Zone	678687	    MERX

How can this be done....?Any help would be greatly appriciated.


Thanks
Sravz


[Edit MC: add code tags and align columns in result, do it yourself]

[Updated on: Sun, 21 June 2009 13:51] by Moderator

Report message to a moderator

Re: updating table 2 [message #409273 is a reply to message #409272] Sun, 21 June 2009 13:51 Go to previous message
Michel Cadot
Messages: 64111
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Just join the tables.

And as said in your previous topic:
Michel Cadot wrote on Wed, 06 May 2009 19:50
...
Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter), use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).
...
Regards
Michel

Previous Topic: how to create schema in this book
Next Topic: Consuming a Java Web Service from PL/SQL using UTL_DBWS
Goto Forum:
  


Current Time: Mon Dec 05 18:51:26 CST 2016

Total time taken to generate the page: 0.09995 seconds