我定义的处理过程如下:
create or replace procedure SP_INT_ERESURE_ERR(li_err_type number)
as
/*cursor cur_err_type_char_set is
select err_type , err_comment
from int_err_char where err_type = li_err_type for update;*/
/*int_errtoright_character是定义的错误字符,error_char 是错误字符列,right_char是正确字符列*/
cursor cur_err_type_char_set is
select error_char , right_char
from int_errtoright_character for update;
r_err_type_char_set cur_err_type_char_set%rowtype;
/* l_count number;*/
begin
open cur_err_type_char_set;
loop
fetch cur_err_type_char_set into r_err_type_char_set;
exit when cur_err_type_char_set%notfound or cur_err_type_char_set%notfound is null;
if li_err_type = 11 then update int_prd_400_product
set product_description =decode(r_err_type_char_set.right_char,null,replace(to_multi_byte(product_description),to_multi_byte(r_err_type_char_set.error_char)) ,replace(to_multi_byte(product_description),to_multi_byte(r_err_type_char_set.error_char),to_multi_byte(r_err_type_char_set.right_char)))
where instr(to_multi_byte(product_description),to_multi_byte(r_err_type_char_set.error_char)) >0 ; --简称中乱字符的处理
update int_prd_400_product
set short_description =decode(r_err_type_char_set.right_char,null,replace(to_multi_byte(short_description),to_multi_byte(r_err_type_char_set.error_char)) ,replace(to_multi_byte(short_description),to_multi_byte(r_err_type_char_set.error_char),to_multi_byte(r_err_type_char_set.right_char)))
where instr(to_multi_byte(short_description) ,to_multi_byte(r_err_type_char_set.error_char)) >0 ;
update int_prd_400_product_last
set product_description =decode(r_err_type_char_set.right_char ,null, replace(to_multi_byte(product_description),to_multi_byte(r_err_type_char_set.error_char)),replace(to_multi_byte(product_description),to_multi_byte(r_err_type_char_set.error_char),to_multi_byte(r_err_type_char_set.right_char)))
where instr(to_multi_byte(product_description),to_multi_byte(r_err_type_char_set.error_char)) >0 ;
--简称中乱字符的处理
update int_prd_400_product_last
set short_description =decode(r_err_type_char_set.right_char ,null, replace(to_multi_byte(short_description),to_multi_byte(r_err_type_char_set.error_char)),replace(to_multi_byte(short_description),to_multi_byte(r_err_type_char_set.error_char),to_multi_byte(r_err_type_char_set.right_char)))
where instr(to_multi_byte(short_description),to_multi_byte(r_err_type_char_set.error_char)) >0 ; elsif li_err_type = 22 then
update int_customer_400_customers set name =decode(r_err_type_char_set.right_char,null,replace(name,r_err_type_char_set.error_char),replace(name,r_err_type_char_set.error_char,r_err_type_char_set.right_char)) /*,name2= replace(name2,r_err_type_char_set.error_char)*/ where instr(name,r_err_type_char_set.error_char)>0;
update int_customer_400_last set name = decode(r_err_type_char_set.right_char,null,replace(name,r_err_type_char_set.error_char),replace(name,r_err_type_char_set.error_char,r_err_type_char_set.right_char))/*,name2= replace(name2,r_err_type_char_set.error_char)*/ where instr(name,r_err_type_char_set.error_char)>0; update int_customer_500_contact_info set address_line = decode(r_err_type_char_set.right_char,null,replace(address_line,r_err_type_char_set.error_char),replace(address_line,r_err_type_char_set.error_char,r_err_type_char_set.right_char)) where instr(address_line,r_err_type_char_set.error_char)>0;
update int_customer_500_contact_info set telephone = decode(r_err_type_char_set.right_char,null,replace(telephone,r_err_type_char_set.error_char),replace(telephone,r_err_type_char_set.error_char,r_err_type_char_set.right_char)) where instr(telephone,r_err_type_char_set.error_char)>0;
update int_customer_500_contact_info set fax =decode(r_err_type_char_set.right_char,null,replace(fax,r_err_type_char_set.error_char),replace(fax,r_err_type_char_set.error_char,r_err_type_char_set.right_char)) where instr(fax,r_err_type_char_set.error_char)>0;
update int_customer_500_contact_info set email = decode(r_err_type_char_set.right_char,null,replace(email,r_err_type_char_set.error_char),replace(email,r_err_type_char_set.error_char,r_err_type_char_set.right_char)) where instr(email,r_err_type_char_set.error_char)>0; update int_customer_500_last set address_line =decode(r_err_type_char_set.right_char,null,replace(address_line,r_err_type_char_set.error_char),replace(address_line,r_err_type_char_set.error_char,r_err_type_char_set.right_char)) where instr(address_line,r_err_type_char_set.error_char)>0;
update int_customer_500_last set telephone =decode(r_err_type_char_set.right_char,null,replace(telephone,r_err_type_char_set.error_char),replace(telephone,r_err_type_char_set.error_char,r_err_type_char_set.right_char)) where instr(telephone,r_err_type_char_set.error_char)>0;
update int_customer_500_last set fax = decode(r_err_type_char_set.right_char,null,replace(fax,r_err_type_char_set.error_char),replace(fax,r_err_type_char_set.error_char,r_err_type_char_set.right_char)) where instr(fax,r_err_type_char_set.error_char)>0;
update int_customer_500_last set email = decode(r_err_type_char_set.right_char,null,replace(email,r_err_type_char_set.error_char),replace(email,r_err_type_char_set.error_char,r_err_type_char_set.right_char)) where instr(email,r_err_type_char_set.error_char)>0;
/*elsif li_err_type = 3 then
elsif li_err_type = 4 then*/
end if; end loop;
close cur_err_type_char_set;
--commit;
/*exception when others then
\*raise_application_error(-20535,sqlerrm); *\*\
rollback;*/
end ;
在这个过程中,我主要用到了两个函数instr(),replace()这两个函数对中文的处理是单字节的处理。而汉字一般都是两个字。在用instr()查找的时候会把正确的也查找出来替换了。请高手给点思路,有不有一个好的解决方法来处理中文的方法。在此先谢谢大家了。
create or replace procedure SP_INT_ERESURE_ERR(li_err_type number)
as
/*cursor cur_err_type_char_set is
select err_type , err_comment
from int_err_char where err_type = li_err_type for update;*/
/*int_errtoright_character是定义的错误字符,error_char 是错误字符列,right_char是正确字符列*/
cursor cur_err_type_char_set is
select error_char , right_char
from int_errtoright_character for update;
r_err_type_char_set cur_err_type_char_set%rowtype;
/* l_count number;*/
begin
open cur_err_type_char_set;
loop
fetch cur_err_type_char_set into r_err_type_char_set;
exit when cur_err_type_char_set%notfound or cur_err_type_char_set%notfound is null;
if li_err_type = 11 then update int_prd_400_product
set product_description =decode(r_err_type_char_set.right_char,null,replace(to_multi_byte(product_description),to_multi_byte(r_err_type_char_set.error_char)) ,replace(to_multi_byte(product_description),to_multi_byte(r_err_type_char_set.error_char),to_multi_byte(r_err_type_char_set.right_char)))
where instr(to_multi_byte(product_description),to_multi_byte(r_err_type_char_set.error_char)) >0 ; --简称中乱字符的处理
update int_prd_400_product
set short_description =decode(r_err_type_char_set.right_char,null,replace(to_multi_byte(short_description),to_multi_byte(r_err_type_char_set.error_char)) ,replace(to_multi_byte(short_description),to_multi_byte(r_err_type_char_set.error_char),to_multi_byte(r_err_type_char_set.right_char)))
where instr(to_multi_byte(short_description) ,to_multi_byte(r_err_type_char_set.error_char)) >0 ;
update int_prd_400_product_last
set product_description =decode(r_err_type_char_set.right_char ,null, replace(to_multi_byte(product_description),to_multi_byte(r_err_type_char_set.error_char)),replace(to_multi_byte(product_description),to_multi_byte(r_err_type_char_set.error_char),to_multi_byte(r_err_type_char_set.right_char)))
where instr(to_multi_byte(product_description),to_multi_byte(r_err_type_char_set.error_char)) >0 ;
--简称中乱字符的处理
update int_prd_400_product_last
set short_description =decode(r_err_type_char_set.right_char ,null, replace(to_multi_byte(short_description),to_multi_byte(r_err_type_char_set.error_char)),replace(to_multi_byte(short_description),to_multi_byte(r_err_type_char_set.error_char),to_multi_byte(r_err_type_char_set.right_char)))
where instr(to_multi_byte(short_description),to_multi_byte(r_err_type_char_set.error_char)) >0 ; elsif li_err_type = 22 then
update int_customer_400_customers set name =decode(r_err_type_char_set.right_char,null,replace(name,r_err_type_char_set.error_char),replace(name,r_err_type_char_set.error_char,r_err_type_char_set.right_char)) /*,name2= replace(name2,r_err_type_char_set.error_char)*/ where instr(name,r_err_type_char_set.error_char)>0;
update int_customer_400_last set name = decode(r_err_type_char_set.right_char,null,replace(name,r_err_type_char_set.error_char),replace(name,r_err_type_char_set.error_char,r_err_type_char_set.right_char))/*,name2= replace(name2,r_err_type_char_set.error_char)*/ where instr(name,r_err_type_char_set.error_char)>0; update int_customer_500_contact_info set address_line = decode(r_err_type_char_set.right_char,null,replace(address_line,r_err_type_char_set.error_char),replace(address_line,r_err_type_char_set.error_char,r_err_type_char_set.right_char)) where instr(address_line,r_err_type_char_set.error_char)>0;
update int_customer_500_contact_info set telephone = decode(r_err_type_char_set.right_char,null,replace(telephone,r_err_type_char_set.error_char),replace(telephone,r_err_type_char_set.error_char,r_err_type_char_set.right_char)) where instr(telephone,r_err_type_char_set.error_char)>0;
update int_customer_500_contact_info set fax =decode(r_err_type_char_set.right_char,null,replace(fax,r_err_type_char_set.error_char),replace(fax,r_err_type_char_set.error_char,r_err_type_char_set.right_char)) where instr(fax,r_err_type_char_set.error_char)>0;
update int_customer_500_contact_info set email = decode(r_err_type_char_set.right_char,null,replace(email,r_err_type_char_set.error_char),replace(email,r_err_type_char_set.error_char,r_err_type_char_set.right_char)) where instr(email,r_err_type_char_set.error_char)>0; update int_customer_500_last set address_line =decode(r_err_type_char_set.right_char,null,replace(address_line,r_err_type_char_set.error_char),replace(address_line,r_err_type_char_set.error_char,r_err_type_char_set.right_char)) where instr(address_line,r_err_type_char_set.error_char)>0;
update int_customer_500_last set telephone =decode(r_err_type_char_set.right_char,null,replace(telephone,r_err_type_char_set.error_char),replace(telephone,r_err_type_char_set.error_char,r_err_type_char_set.right_char)) where instr(telephone,r_err_type_char_set.error_char)>0;
update int_customer_500_last set fax = decode(r_err_type_char_set.right_char,null,replace(fax,r_err_type_char_set.error_char),replace(fax,r_err_type_char_set.error_char,r_err_type_char_set.right_char)) where instr(fax,r_err_type_char_set.error_char)>0;
update int_customer_500_last set email = decode(r_err_type_char_set.right_char,null,replace(email,r_err_type_char_set.error_char),replace(email,r_err_type_char_set.error_char,r_err_type_char_set.right_char)) where instr(email,r_err_type_char_set.error_char)>0;
/*elsif li_err_type = 3 then
elsif li_err_type = 4 then*/
end if; end loop;
close cur_err_type_char_set;
--commit;
/*exception when others then
\*raise_application_error(-20535,sqlerrm); *\*\
rollback;*/
end ;
在这个过程中,我主要用到了两个函数instr(),replace()这两个函数对中文的处理是单字节的处理。而汉字一般都是两个字。在用instr()查找的时候会把正确的也查找出来替换了。请高手给点思路,有不有一个好的解决方法来处理中文的方法。在此先谢谢大家了。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货