Cursor in MySQL stored procedures

MySQL SELECT

Cursor allows you to iterate a group of rows fetched by a query and process each row. It is read only, non-scrollable and asensitive.

Declare a cursor:

DECLARE <cursor_title> CURSOR FOR SELECT_statement;

Open a cursor:

OPEN <cursor_title>;

Fetch cursor:

FETCH <cursor_title> INTO variables list;

Close cursor:

CLOSE <cursor_title>;

Leave a Reply

Your email address will not be published. Required fields are marked *