title: insert into the table from one to another using cursor in store procedure
body: <p>i created two table student and grade. the student table contains the column of id(PK),name,mark,address. and i inserted 10 values to it. in the grade table there are two coulmns stud_id(foreign key)and stud_status. and in grade i have to write a cursor inside store procedure, to insert into the grade table from the student table. the condition will be like if the student mark is above 50 inthe grade table it should be store as 'G' in stud_status and the stud_id too for it. if the mark =50 it should store 'E' and else are'L'
  i use the below code. and iam using MySQL Workbench 6.0.</p>
  
  <pre><code>    use test;
      delimiter $$
      drop procedure if exists `p_status` $$
      create procedure `p_status`()
         begin
        declare s_stud_mark int(111);
         declare s_stud_id int(111);
         declare cur_stud cursor For Select stud_id,stud_mark from  student where stud_id                is not null;
           open cur_stud;
            fetch cur_stud into s_stud_mark,s_stud_id;
           if(stud_mark &gt; 50) then
           set s_stud_mark='G';
              insert into grade(`stud_id`,`stud_staus`)values(s_stud_id,s_stud_mark);
            else if(stud_mark = 50) then
           set s_stud_mark='E';
            insert into grade(`stud_id`,`stud_status`) values(s_stud_id,s_stud_mark);
             else
              set s_stud_mark='L';
              insert into grade(`stud_id`,`stud_status`)values(s_stud_id,s_stud_mark);
             end if ;
            end if ;
           close cur_stud;
           end $$
           delimiter ;
  </code></pre>
  
  <p>but it shows error as "Error Code: 1054. Unknown column 'stud_mark' in 'field list'"</p>
  
  <p>anyone reply</p>