https://blog.faq400.com/en/db2-for-i/db2-for-i-sql-functions-en/
Smarter SQL functions with control statements