Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SQL/PL/SQL

PS SPAug 10 2021

I have a taken following code from Community,

SET SERVEROUTPUT ON;
DECLARE
v_Str VARCHAR2(100);
V_STR2 VARCHAR2(100);
result1 VARCHAR2(100);
BEGIN
v_Str := '600,1001,500,200,300,400' ;
v_Str2 :='100,200' ;
with testdata as(
select v_Str v_test1, v_Str2 v_test2 from dual )
select
trim(',' from
regexp_replace(
regexp_replace(','||replace(v_test1,',',',,')||','
,','||replace('('||v_test2||')',',',')|(')||','
)
,',{2,}',','
)
) result into result1
from testdata ;
DBMS_OUTPUT.PUT_LINE ( 'Result set values are: '||result1 );
END;

Result Set coming in following way:
PL/SQL procedure successfully completed.
Result set values are: 600,1,500,300,400
I need in such a way : 1001 is not in v_str2 but its getting partial string replace, I want only if the string exact match then it should find/ replace or it should ignore. Can any one please help?

Thanks

This post has been answered by Frank Kulash on Aug 10 2021
Jump to Answer
Comments
Post Details
Added on Aug 10 2021
3 comments
82 views