1415
MariaDBerrorstored-procedureshigh confidence
Not allowed to return a result set from a function
Production Risk
Low — function fails at runtime or compile time.
What this means
A stored function contained a SELECT statement that would return a result set to the client rather than assigning to a variable.
Why it happens
- 1Using a bare SELECT inside a CREATE FUNCTION body
- 2Calling a procedure that returns a result set from within a function
How to reproduce
trigger — this will error
trigger — this will error
CREATE FUNCTION f() RETURNS INT BEGIN SELECT * FROM t; RETURN 1; END;
expected output
ERROR 1415 (0A000): Not allowed to return a result set from a function
Fix
Use SELECT INTO
Use SELECT INTO
SELECT col INTO local_var FROM t WHERE id = 1;
Why this works
Assigns the value to a local variable without returning a result set.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 1415 ER_SP_NO_RETSET
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev