I have a MySQL Cursor, but I need to set it as read-only and not-scrollable, but how can I set it in the stored procedure?
My stored procedure looks like
DROP PROCEDURE IF EXISTS `GetAllNonprocessedSMSes` €€
CREATE PROCEDURE `GetAllNonprocessedSMSes`()
BEGIN
...
DECLARE id_cur CURSOR FOR
SELECT `id` FROM (
SELECT
MIN(`id`) AS `id`
FROM
`inbox`
WHERE
`Processed`='false'
AND `udh`=''
) AS `baseview`
ORDER BY `id`;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET finish = TRUE;
OPEN id_cur;
the_loop : LOOP
FETCH id_cur INTO smsid;
...
END LOOP the_loop;
...
END €€
You don’t mention which version of MySql you are using, but according to the MySQL 5.0 reference manual:
“MySQL supports cursors inside stored programs. The syntax is as in embedded SQL. Cursors have these properties:
– Asensitive: The server may or may not make a copy of its result table
– Read only: Not updatable
– Nonscrollable: Can be traversed only in one direction and cannot skip rows”
Therefore, I would say that MySql cursors are, by definition, read-only AND nonscrollable !