Tuesday, January 22, 2013

PL/SQL for loop example

Following PL/SQL script updates all phone number in user table using a simple for loop.
DECLARE
  phone_no varchar2(100) := null;
BEGIN
  FOR r1 IN (select user_name from tbl_user where phone is null) LOOP
    select phone into phone_no from tbl_profile where user_name = r1.user_name;
    update tbl_user set phone = phone_no where user_name = r1.user_name;
  END LOOP;
END;

2 comments:

sathya shri said...

I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.Rprogramming Training in chennai

Janardhan said...

Usually I never comment on blogs but your article is so convincing that I never stop myself to say something about it. You’re doing a great job,Keep it up.

Try Our BLACK MAGIC REMOVAL EXPERT IN TORONTO
Services and Get All the benefits of it in your life, we make All your Personal problems solved in just minutes.