|
-
The following example replaces abbreviations with un-abbreviated words:
Code:
drop table full_job_ttl
/
create table full_job_ttl
as
select * from job_ttl
/
alter table full_job_ttl
add (full_title varchar2(200))
/
set serverout on size 1000000;
declare
type txt_typ is table of varchar2(200)
index by binary_integer;
type rowid_typ is table of rowid
index by binary_integer;
v_abb txt_typ;
v_una txt_typ;
v_ttl txt_typ;
v_full_ttl txt_typ;
v_row rowid_typ;
i pls_integer;
j pls_integer;
k pls_integer;
l pls_integer;
begin
select abbrev, un_abbrev bulk collect
into v_abb, v_una
from job_ttl_abbrev
;
select rowid, title bulk collect
into v_row, v_ttl
from full_job_ttl
;
for j in 1..v_abb.count
loop
if NVL(v_una(j),'?') = '?' then
v_una(j):='?'||v_abb(j);
end if;
end loop;
for i in 1..v_row.count
loop
v_full_ttl(i):=RTRIM(UPPER(v_ttl(i)));
for j in 1..v_abb.count
loop
if length(v_full_ttl(i)) > length(v_abb(j)) and
substr(v_full_ttl(i),1,length(v_abb(j))+1) = v_abb(j)||' ' then
v_full_ttl(i):=v_una(j)||substr(v_full_ttl(i),length(v_abb(j))+1);
end if;
k:=instr(upper(v_full_ttl(i)),' '||v_abb(j)||' ');
if k>0 then
v_full_ttl(i):=substr(v_full_ttl(i),1,k)||v_una(j)
||substr(v_full_ttl(i),k+length(v_abb(j))+1);
end if;
k:= length(v_full_ttl(i)) - length(v_abb(j));
if length(v_full_ttl(i)) > length(v_abb(j)) and
substr(v_full_ttl(i),k) = ' '||v_abb(j) then
v_full_ttl(i):=substr(v_full_ttl(i),1,k)||v_una(j);
end if;
end loop;
v_full_ttl(i):=RTRIM(INITCAP(v_full_ttl(i)));
dbms_output.put_line(v_ttl(i)||' -> '||v_full_ttl(i));
end loop;
forall i in 1..v_row.count
update full_job_ttl
set full_title = v_full_ttl(i)
where rowid = v_row(i)
;
commit;
end;
/
"The person who says it cannot be done should not interrupt the person doing it." --Chinese Proverb
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|