Hello,
Nice reply Josh.
I wouldn't call your solution 'ugly' at all.
It's an excellent example of a real world need for Postgresql functions.
I've also been looking at other functions at
http://www.brasileiro.net/postgres/cookbook/.
I noticed your name amongst the author's -- nice one -- keep up the good
work.
My only problem is trying to decide on whether to use PL/pgSQL or PLPerl.
Cheers
Rudi