As per documentation on loadable user defined functions in MySQL
you can only return values of type {STRING|INTEGER|REAL|DECIMAL}
CREATE [AGGREGATE] FUNCTION function_name RETURNS {STRING|INTEGER|REAL|DECIMAL}
SONAME shared_library_name
If you want to read a select
resultset you have to define a procedure
but not function
.
DELIMITER //
DROP PROCEDURE IF EXISTS myProcedure //
CREATE PROCEDURE
myProcedure( id INT )
BEGIN
SELECT * FROM board
-- add where condition if required
WHERE Col_name = id
;
END
//
DELIMITER ;
And you can call procedure like
call myProcedure( 6 )
That returns implicit objects based on the statements used in the procedure.
Also Refer to:
Adding a Loadable Function
- Functions can return string, integer, or real values and can accept
arguments of those same types