• you are not allowed to use the RAND() function inside UDF function. To call the value of this function create a view with the single statement select RAND()

    And then call that view inside your function.