Define convenience functions for UDFs.

sqlvalue retrieves the i-th value from values.
sqlreturn returns a value of the correct type.
sqlerror raises and error.
Implement regex function using conv methods.