|
|||
|
Hello
Pls Help me for following Problem in PL/SQL
select strreplace('This is a beautiful day!', 'beautiful', 'horrible') from dual The given query selects the string 'This is a horrible day!'. The string 'beautiful' is replaced by 'horrible'. Write the function strreplace. without using replace / translate function in pl/sql we have to solve above problem.could you any one help me... |
| Sponsored Links |
|
|||
|
Hi hope that this solves ur problem..
function strreplace(parent_string varchar2(100), to_replace varchar2(50), replace_by varchar2(50)) return varchar2 as string1 varchar2(100); string2 varchar2(100); final varchar2(200); begin string1 = substr(parent_string,1, instr(parent_string,to_replace,1,1) - 1) string2 = substr(parent_string,length(to_replace) + instr(parent_string,to_replace,1,1), length(parent_string)) final_string = string1||replace_by||string2 return(final_string); end; regards, RaJ |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
|
|