Tuesday, July 20, 2010

Bulk Updation in Address: Move one column data to another

Declare

cursor CUR_TAB is

SELECT rowid,a.*

FROM accountaddressdetail11 a WHERE CODE LIKE 'In%';

l_b number:=0;

Begin

for CUR_REC in CUR_TAB

loop

Begin

if CUR_REC.TEL2 is not null then

if CUR_REC.TEL1 is null or LENGTH(TRIM(CUR_REC.TEL1)) is null then

update accountaddressdetail11 set TEL1=CUR_REC.TEL2,TEL2=' ' where rowid=CUR_REC.rowid and TEL2=CUR_REC.TEL2 ;

elsif CUR_REC.TEL3 is null or LENGTH(TRIM(CUR_REC.TEL3)) is null then

update accountaddressdetail11 set TEL3=CUR_REC.TEL2,TEL2=' ' where rowid=CUR_REC.rowid and TEL2=CUR_REC.TEL2;

elsif CUR_REC.MOBILE is null or LENGTH(TRIM(CUR_REC.MOBILE)) is null then

update accountaddressdetail11 set MOBILE=SUBSTR(CUR_REC.TEL2,1,12),TEL2=' ' where rowid=CUR_REC.rowid and TEL2=CUR_REC.TEL2;

elsif CUR_REC.PAGER is null or LENGTH(TRIM(CUR_REC.PAGER)) is null then

update accountaddressdetail11 set PAGER=SUBSTR(CUR_REC.TEL2,1,12),TEL2=' ' where rowid=CUR_REC.rowid and TEL2=CUR_REC.TEL2;

end if;

end if;

Exception

when others then

null;

End;

end loop;

End;

-----------------------------------

No comments:

Post a Comment

Followers