Anyone got any ideas why this function was made to work this way? Makes no sense to me.
I cannot answer that authoritatively, but consider that it would make no sense to try to replace part
of a string with NULL either, so perhaps the decision was made to check the types of all three parameters first before doing the matching.
edit: fix typo
I guess my question is why does the REPLACE function replace anything if the string pattern (second parameter) isn't in the string expression (first parameter)?
For example, this doesn't return 'bbb':
SELECT REPLACE('Hello world', 'zzz', 'bbb');
So why should
SELECT REPLACE('Hello world', 'zzz', NULL);
Thanks in advance for any help,
"I love spending twice as long and working twice as hard to get half as much done!" – Nobody ever.
"Operator! Give me the number for 911!" - Homer Simpson
"A SQL query walks into a bar and sees two tables. He walks up to them and says 'Can I join you?'"