Oracle removes duplicate strings

Source: Internet
Author: User

Create or Replace functionRemove_same_string (oldstrvarchar2, Sign varchar2)return varchar2  is  /**************************************************** * * Oracle Removes duplicate String * * Function Name: REMOVESAMESTR * * parameter: "Name" "  Type "description" * * OLDSTR VARCHAR2 string to process * * Sign VARCHAR2 string delimiter * * return value: Result VARCHAR2 records that do not contain duplicate substrings ****************************************************/  Str          varchar2( -); Currentindex Number; StartIndex Number; EndIndex Number; Type Str_type is Table  of varchar2( -)Index  byBinary_integer;  Arr Str_type; Resultvarchar2( +);begin  --empty string  ifOldstr is NULL  Then    return("'); End if; --string Too long  ifLength (OLDSTR)>  -  Then    return(OLDSTR); End if; Str:=Oldstr; Currentindex:= 0; StartIndex:= 0; Loop Currentindex:=Currentindex+ 1; EndIndex:=InStrStr, Sign,1, Currentindex); if(EndIndex<= 0) Then      Exit; End if; Arr (currentindex):=Trim (substr (Str, StartIndex+ 1, EndIndex-StartIndex- 1)); StartIndex:=EndIndex; EndLoop; --take the last string:Arr (currentindex):=SubstrStr, StartIndex+ 1, Length (Str)); --Remove the repeated occurrences of the string:   forIinch 1.. Currentindex- 1Loop forJinchI+ 1.. currentindex LoopifArr (i)=Arr (j) ThenArr (j):= "'; End if; EndLoop; EndLoop; Str:= "';  forIinch 1.. currentindex LoopifArr (i) is  not NULL  Then      Str:= Str ||  Sign ||arr (i); --Array Empty:Arr (i):= "'; End if; EndLoop; --Remove the preceding identifier:Result:=SubstrStr,2, Length (Str)); return(Result);Endremove_same_string;

Oracle removes duplicate strings

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.