While importing the database in mysql, I have got following error:
1418 (HY000) at line 10185: This function has none of DETERMINISTIC, NO SQL, or READS SQL DA
Try setting the definer for the function!
So instead of
CREATE FUNCTION get_pet_owner
you will write something akin to
CREATE DEFINER= procadmin@% FUNCTION get_pet_owner
which ought to work if the user prodacmin has rights to create functions/procedures.
In my case the function worked when generated through MySQL Workbench but did not work when run directly as an SQL script. Making the changes above fixed the problem.