> RETURN NEXT reply;
I think Return next is incorrect. try return reply;
> One thought -- does my "UPDATE" line need to be in a transaction section?
by default it already is <I believe>. All syntax in a function is executed inside a single
calling transaction.