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