1306
MariaDBerrorstored-procedureshigh confidence
Not allowed to return a result set from a trigger
Production Risk
Low — trigger compilation fails.
What this means
A SELECT statement that would return a result set to the client was used inside a trigger body.
Why it happens
- 1Using a bare SELECT inside a trigger
- 2Calling a stored procedure that returns a result set from within a trigger
How to reproduce
trigger — this will error
trigger — this will error
CREATE TRIGGER t BEFORE INSERT ON orders FOR EACH ROW BEGIN SELECT * FROM products; END;
expected output
ERROR 1306 (0A000): Not allowed to return a result set from a trigger
Fix
Use SELECT INTO instead
Use SELECT INTO instead
SELECT col INTO @var FROM t WHERE id = NEW.id;
Why this works
Captures the value without returning a result set to the client.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 1306 ER_SP_BADSTATEMENT
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev