Live ORACLE

if you are Oracle Developer ,than this Blog most likely will make you happy.

About my Blog

This Blog particularized for Oracle Developers ... you will see interesting Codes for SQL , PL/SQL as well as new ideas for Developer Suite and Client Tools that will help you in your professional life ... and I hope I reach for your satisfaction.

About Me

I'm Hany Freedom , 25 years old , I live in EL-Minia City in Egypt , I'm Moderator at ArabOUG.org the best Arabic Forum for ORACLE on the Net. if you interested to know more about me .... just Click Here.

Using the Function REPLACE


DECLARE

string_type VARCHAR2(60);

old_string string_type%TYPE := 'Apples and oranges';

v_string string_type%TYPE := 'more apples';

-- NULL is a valid argument to REPLACE, but does not match

-- anything so no replacement is done.

new_string string_type%TYPE := REPLACE(old_string,NULL,v_string);

BEGIN

dbms_output.Put_line('Old string = '

||old_string);



dbms_output.Put_line('New string = '

||new_string);

END;

/



If its third argument is null,
REPLACE returns its first argument with every occurrence of its second argument removed. For example, the following call to REPLACE removes all the dashes from DASHED_STRING, instead of changing them to another character:


DECLARE

string_type VARCHAR2(60);

dashed string_type%TYPE := 'Gold-i-locks';

-- When the substitution text for REPLACE is NULL,

-- the text being replaced is deleted.

NAME string_type%TYPE := REPLACE(dashed,'-',NULL);

BEGIN

dbms_output.Put_line('Dashed name = '

||dashed);



dbms_output.Put_line('Dashes removed = '

||NAME);

END;

/



If its second and third arguments are null,
REPLACE just returns its first argument.


Share/Save/Bookmark

0 comments:

Post a Comment



Newer Posts Older Posts Home Page
 
http://www.dpriver.com/images/sqlpp-banner-2.png

Thanks for reading my Blog ... you Visitor Number :-