title: SQL 'After insert trigger' complains of unknown column 'currentId' in field list, which is cursor
body: <p>I have 2 tables.  </p>
  
  <pre><code>create table comments (
      id int auto_increment primary key,
      task_id int not null,
      foreign key fk_comment_task(task_id) references tasks(id),
      user int not null,
      foreign key fk_comment_user(user) references users(id),
      comment varchar(1000) not null,
      comment_date date not null,
      viewed tinyint(1) not null default 0,
      deleted tinyint(1) not null default 0   
  ) engine = InnoDB;
  </code></pre>
  
  <p>and a second one:</p>
  
  <pre><code>create table viewed_comments (
      id int auto_increment primary key,
      comment int not null,
      foreign key fk_viewed_comment(comment) references comments(id),
      viewer int not null,
      foreign key fk_viewed_viewer(viewer) references users(id),
      unread tinyint(1) not null default 0,
      deleted tinyint(1) not null default 0
  ) engine = InnoDB;
  </code></pre>
  
  <p>I want to create a trigger that says when a comment is inserted into the 'comments' table, the 'viewed_comments' table creates rows for that comment for all users except the one submitting the comment.</p>
  
  <p>At the moment, I have a trigger:</p>
  
  <pre><code>delimiter |
  create trigger ins_views after insert on comments 
  for each row 
      begin
          DECLARE finished INT DEFAULT 0;
          DECLARE id INT DEFAULT 0;
  
          DECLARE currentId CURSOR FOR SELECT id FROM users WHERE id != NEW.user;
  
          DECLARE CONTINUE HANDLER 
              FOR NOT FOUND SET finished = 1;
  
          OPEN currentId;
  
          update_views_loop: LOOP
              FETCH currentId INTO id;
              IF finished = 1 THEN LEAVE update_views_loop;
  
              END IF;
              INSERT INTO viewed_comments (comment, viewer) VALUES (NEW.id, currentId);   
  
          END LOOP update_views_loop;
  
       CLOSE currentId;
  
      END;
  |
  
  delimiter ;
  </code></pre>
  
  <p>When I do an insert into the such as 'insert into comments (task_id, user, comment, comment_date) values (24, 4, 'test', '2018-3-5'); as an example, I get the following response.
  ERROR 1054 (42S22): Unknown column 'currentId' in 'field list' which is the cursor.  How do I fix this?</p>