![]() Since ‘hello’ is present 1 time in the expression, it would be replaced with ‘hi’ in the input expression. The REPLACE function used above has 3 parameters ‘Tst_String’ which has a string expression, string_to_replace is ‘hello’ and the replacement_string is ‘hi’. Tst_String string(25) := 'hello how are you' ĭbms_output.put_line(REPLACE(Tst_String, 'hello', 'hi')) Įxplanation: In the above code, string1 or the string expression is ‘hello how are you’. So, the resulting string expression is ‘elloello’ removing all the occurences of ‘h’. ![]() So, first, the string ‘hi’ is searched in the string expression and will be removed from it. There is no replacement_string in the above REPLACE function. ‘Tst_String’ which has a string expression and the string_to_replace is ‘h’. REPLACE function used above has 2 parameters, i.e. Some of the examples of PL/ SQL showing the implementation of REPLACE function in the code are given below:ĭbms_output.put_line(REPLACE(Tst_String, 'h')) Įxplanation: In the above code, string1 or the string expression is ‘hellohello’. Supported versions Oracle which supports the REPLACE function in PL/ SQL are given below: Function returns the removed characters string. It removes all the occurrences of string_to_replace in the string1. If the replacement_string is not present in the REPLACE function of PL/ SQL, it works for the removal of string characters.The REPLACE function of PL/ SQL provides the functionality somewhat similar to that of TRANSLATE function, only difference being that TRANSLATE allows one-to-one substitution whereas REPLACE allows replacement of string/ characters, even removal of character strings (in case of omission of Optional parameter).The resulting string is of the same character set as char. string1, string_to_replace and replacement_string can be of any data type, i.e. In case when the string_to_replace( string to be searched) is null, it will return the same string1 (input string expression).string1( input string), string_to_replace (string to be searched), replacement_string (Optional. It accepts 3 parameters in which 1 parameter is Optional, i.e.The REPLACE function of PL/SQL is used to replace a sequence of string with another set of string/ characters.How does the PLSQL Replace Function Work?īelow given are some of the important points which needs to keep in mind related to the working of REPLACE function in PL/SQL: Return type: The REPLACE function returns the string value to the user.If the replacement_string is not present in the string expression, all the occurrences of ‘replacement_string’ are removed from the string1. All the occurrences of ‘string_to_replace’ will be replaced with ‘replacement_string’. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |