title: create a trigger to alter table add column based on inserted row
body: <p>I have two tables in a database named as follows: </p>
  
  <pre><code>1. state_master
  +---------------+-------------------+
  |      state_id |        state_name |
  +---------------+-------------------+
  |             1 |               new |
  |             2 |          assigned |
  |             3 |       in_progress |
  |             4 |           on_hold |
  |             5 |            closed |
  +---------------+-------------------+
  
  
  
  2. store_complaint_state_count
  +----------+-----+--------+------------+-------+------+
  | store_id | new |assigned| in_progress|on_hold|closed|          
  | 101      | 1   |2       | 2          |0      |0     |
  | 102      | 5   |4       | 1          |0      |2     |
  +----------+-----+--------+------------+-------+------+
  </code></pre>
  
  <p>Now I want to add another row in state_master state_id =6 and state_name=reopen.
  I want to create a trigger which can alter table store_complaint_state_count and add column reopen in it.</p>
  
  <p>I've created a procedure:</p>
  
  <pre><code>CREATE DEFINER=`root`@`localhost` PROCEDURE `alterTablestorewisecomplaintcount`(in state int )
  BEGIN
      alter table storewisecomplaintcount
      add column state INT UNSIGNED ZEROFILL NOT NULL DEFAULT 0;
  
  END
  </code></pre>
  
  <p>And a trigger:</p>
  
  <pre><code>CREATE DEFINER = CURRENT_USER
      TRIGGER `nxtlife_sfcms_db_v2`.`complaint_state_AFTER_INSERT`
      AFTER INSERT ON `complaint_state`
  
  FOR EACH ROW
  
  BEGIN
  
  call alterTablestorewisecomplaintcount(new.state_value);
  
  END
  </code></pre>
  
  <p>But it throws an error at the time of insertion:</p>
  
  <blockquote>
    <p>ERROR 1422: 1422: Explicit or implicit commit is not allowed in stored function or trigger.</p>
  </blockquote>