<< This doesn't work, and I don't understand why >>
EDB expects only one RETURN statement as the last statement in the function.
To do what you want, you'll need to use a variable and return it instead.
It's a little restrictive, so I may relax this a little later.