Hi all,
How do we replace string with quotes.
like i have input parameter v_in_stores passed as 'AB,CD'
In output i am calling below statement .
v_main:- v_main||'STORE IN (''' || v_in_stores ||''')';
I want 'AB,CD' to be replaced as 'AB','CD'
in the output STORE IN clause.Please guide
Thanks
Yoda
December 4, 2012, 3:45pm
2
select '''' || substr(v_in_stores,1,2) || ''',' || '''' || substr(v_in_stores,4,5) || '''' from dual;
select '''' || substr('AB,CD',1,2) || ''',' || '''' || substr('AB,CD',4,5) || '''' from dual;
'AB','CD'
Hi Bipinajith,
Thanks for the reply .
I am calling the output in oracle package.If the input varies
say v_in_stores as 'AB,CD,EF' or any alphapets followed within string.
will the code change to 'AB','CD','EF'
PLEASE ADVICE
This should work for you:
select '''AB,CD,EF''', regexp_replace( '''AB,CD,EF''', ',', ''',''' ) from dual
1 Like
Yoda
December 5, 2012, 12:31am
5
select regexp_replace('AB,CD','([[:alpha:]]{2})',q'['\1']') from dual;
'AB','CD'
select regexp_replace('AB,CD,EF','([[:alpha:]]{2})',q'['\1']') from dual;
'AB','CD','EF'
1 Like
Thanks Guys !!! It worked fine .