0

I am trying a simple trigger to print id of a table but it's throwing #2014 - Commands out of sync; you can't run this command now

CREATE TABLE `cursor_test` (
  `id` bigint(21),
  `name` varchar(10) DEFAULT NULL
)
DELIMITER //
CREATE PROCEDURE print_cursor_test()
BEGIN
    DECLARE temp_id INT;

    DECLARE print_test CURSOR FOR
        SELECT id FROM cursor_test;

    DECLARE CONTINUE HANDLER FOR NOT FOUND SET @done = TRUE;

    OPEN print_test;

    read_loop: LOOP

        FETCH print_test INTO temp_id;

        IF @done THEN
            LEAVE read_loop;
        END IF;

        IF temp_id IS NOT NULL THEN
            SELECT temp_id;
        END IF;

    END LOOP;

    CLOSE print_test;

END //

DELIMITER ;

call print_cursor_test()

I am running it on mariaDB 10.4 and using myphpadmin interface to run it.

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
Gan3i
  • 95
  • 11

0 Answers0