However, perhaps I don't understand the idea of a function.
pgsql-general by date:
Соглашаюсь с условиями обработки персональных данных