1315
MySQLerrorstored-procedureshigh confidence

Cursor SELECT must not have INTO

Production Risk

Low — compile-time error; routine not created.

What this means

A cursor was declared with a SELECT ... INTO statement; INTO is not allowed in cursor declarations.

Why it happens
  1. 1Copy-pasting a SELECT ... INTO from regular code into a CURSOR FOR clause
How to reproduce
trigger — this will error
trigger — this will error
DECLARE cur CURSOR FOR SELECT id INTO @v FROM t;

expected output

ERROR 1315 (42000): Cursor SELECT must not have INTO

Fix

Remove INTO from cursor SELECT

Remove INTO from cursor SELECT
DECLARE cur CURSOR FOR SELECT id FROM t;

Why this works

Use FETCH cur INTO @v; to assign values from the cursor.

Sources
Official documentation ↗

MySQL 8.0 — 1315 ER_SP_BAD_CURSOR_SELECT

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MySQL errors