Showing posts with label plsql. Show all posts
Showing posts with label plsql. Show all posts

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;

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

Bulk Updation: update EmailCC column

Declare
cursor CUR_BULK_UPDATE is
SELECT rowid,a.* FROM ACCOUNTEMAILDETAIL a WHERE CODE NOT LIKE '%M';
l_b number:=0;
Begin
for CURSOR_RECURSION in CUR_BULK_UPDATE
loop
Begin
if CURSOR_RECURSION.EMAIL is not null then
update ACCOUNTEMAILDETAIL set CEMAILCC= (trim(LOWER(CURSOR_RECURSION.OOWNCODE))) ||'@uniconglobal.com' where rowid=CURSOR_RECURSION.rowid and

CURSOR_RECURSION.EMAIL ! = ' ' and CURSOR_RECURSION.EMAIL not like '%@uniconglobal.com%';
end if;
Exception
when others then
null;
End;
end loop;
End;
/
COMMIT;

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

Followers