What is this Site!!

All about Real time requirements in Orale Stay Tune!!

Friday, December 7, 2007



Update B with the Help of A


I am in great problem since last 3 days by the following problem.

I have 2 tables as A and B both having 2 fields as name and roll. I have to update the B table with respect to table A.

Can we do this with the help of query.
I have written a code for this and giving error and system goes to infinite loop.

The code is following:

Declare
cursor c1 is select * from A where roll IN ( select roll from B);
rec_set emp1%rowtype;
begin
open c1;
fetch c1 into rec_set;
loop
update B set B.name=rec.set.name where B.roll=rec_set.roll;
end loop;
close c1;
end;

When I complied this block, it then goes to infinite and then I need to stop its services to again login the system.

Looks like in the line

update B set B.name=rec.set.name where B.roll=rec_set.roll;

the underlined part should be rec_set

I think this could be done using a single query also

update B

set B.name = (select name from A T1where T1.roll = B.roll)
be careful the above query will be valid only if the embedded query returns just one row.



2 comments:

Anonymous said...

Such a nice blog, I really like what you write in this blog, I also have some relevant Information about Best HR Training In Hyderabad | Hr training institute in Hyderabad! if you want more information.
Oracle Fusion HCM Online Training
Oracle Fusion Financials Online Training

Rainbow Training Institute said...

Really very helpful article , Thank you for sharing

Spark and Scala Online Training
Spark Scala Training
Hyderabad