如题所述
ä¸ãé®é¢è¯´æ
å¨å¤çæ°æ®çæ¶åï¼éè¦å¤ææ个å段å符串ä¸æ¯å¦æä¸æï¼è¥æåååºä¸æã
äºã解å³åæ³
é¦å å¦ä½å¤ææ个å段å符串ä¸æ¯å¦æä¸æãè¿éä»ç»ä¸ç§æ¹æ³ï¼
1ãéç¨ASCIISTRå½æ°
说æï¼ASCIISTRå½æ°ç¨äºè¿åå符çASCIIå½¢å¼çå符串ï¼éASCIIçå符被转å为\xxxxçå½¢å¼ãæ¢å¥è¯è¯´ï¼å¦æå符ä¸å å«ä¸æï¼åå¿ å®ä¼æ\xxxxçå符ã
æ以ï¼æ们ç´æ¥å©ç¨ASCIISTRå½æ°å¹é '\'å³å¯å¤æã
2ãéç¨lengthålengthbçåç
说æï¼ä¸æä¸lengthè¿åçæ¯å符个æ°ï¼ä¸æå 1å符ï¼lengthbè¿åçæ¯åè个æ°ï¼ä¸æå 2åèï¼æ ¹æ®ä¸æçç¹æ§å³å¯è§£å³ã
3ã使ç¨CONVERTå½æ°å¤å«
说æï¼CONVERT(è¦è½¬æ¢çå符串,ç®æ å符é,åå符é)ï¼CONVERTå½æ°ç¨äºè½¬æ¢å符串çå符éï¼æ以æ们å¯ä»¥å©ç¨ä¸æçå符éæ¯utf-8æ¥å¤æã
ä¸é¢ä»ç»äºå¦ä½å¤ææ个å段å符串ä¸æ¯å¦æä¸æï¼å¨æåå¤æå段ä¸æ¯å¦æä¸æä¹åï¼é£ä¹è¯¥å¦ä½ååºå段ä¸çä¸æå¢ï¼
è¿éä»ç»ä¸ç§å¿«éåç¡®çåæ³ï¼
å½æ°å建æååï¼ç´æ¥ä¼ jldwè°ç¨å°±å¯è·å该å符çä¸æäºã
æºç å¦ä¸ï¼
create or replace function getCustText(custName varchar2) return varchar2 is
Result varchar2(100); --è¿åçç»æå符串
tmp_custName varchar2(100); --临æ¶åé
count_str number; --å符串ä¸å符ç个æ°
i number:=1; --循ç¯åé
str_ascii number; --å½åçå¾
å¤æå符çasciiç
current_char varchar2(10); --å½åçå¾
å¤æçå符
begin
select length(custName) into count_str from dual; --ååºå¾
å¤çå符串çé¿åº¦
while i<count_str loop ---æ ¹æ®å¾
å¤çå符串é¿åº¦ï¼countsï¼?ï¼é个å符å¤æå¤ç
current_char:=substr(custName,i,1);
select ASCII(current_char) into str_ascii from dual;
if str_ascii>45216 then
tmp_custName:=tmp_custName||current_char;
end if;
i:=i+1;
end loop;
Result:=tmp_custName;
return(Result);
end getCustText;