Is there a reason why the second line uses UPPER() instead of LOWER()?
I'm trying to test this just using the code inside the function and it is taking a damn long time to convert one little string. 4 minutes and counting so far.
Edit: Ah. Just saw your post about the caret mark. That makes the code go so much faster.