chickadee » sql-de-lite » register-scalar-function!

register-scalar-function! db name nargs procprocedure

Register a user-defined scalar function name of arity nargs. nargs may range from 0 to 127, or -1 to define a function taking any number of arguments. You may define multiple functions with differing numbers of arguments. Defining a function with the same nargs as an existing function will redefine it, even built-in functions.

proc should be a function taking nargs arguments; to delete an existing function, set proc to #f. The return value is used as the value of the scalar function. If an error occurs during the function, it is signaled as a database error.

Functions must be defined anew for every database connection.

Be very careful when combining user-defined functions and SRFI-18 threads.