personally they way I do it, is by creating temporary table, intransaction - and use it in function. Obviously that's very indirect,and not obvious if you see function's declaration. But works fine.