How to remove spaces between words and replace with single underscore using 'REPLACE','INSTR' OR 'SUBSTR' oracle function I want to replace spaces between words with a single underscore. I can't use the replace_regex Oracle function to do this, because it is not supported by the converter which we are using to convert sql statements so that they will be independent of platform such as SQL Server, PostgreSQL etc. . 

Currently converter is providing support for 'substr' , 'replace', and 'instr' oracle functions. how can i use these three functions to get below output. 
Example:

"my name is            xyz" =&gt;  "my_name_is_xyz"
"test    sdf"               =&gt;  "test_sdf"
Something like this might work for you, at least if replace does the same on all your platforms as in SQL Server.


Replace all spaces with space+underscore
Replace underscore+space with an empty string
Replace space with an empty string




replace(replace(replace('my name is            xyz', ' ', '_ '), ' _', ''), ' ', '');