title: stored procedure and triggers in mysql
body: <p>I'm  trying to run a stored procedure that will insert data to the table. In in the table, there is a trigger after add that will update the sequence table(there is no sequence in MySQL DB)</p>
  
  <p>This is my stored procedure:</p>
  
  <pre><code>DELIMITER $$
  
  CREATE DEFINER=`dbName`@`%` PROCEDURE `insertGuide`(m_name varchar(45)  ,m_last varchar(45) ,addres varchar(45) ,mphone int)
  BEGIN
  
  INSERT INTO `guides` (`id`, `name`, `lastName`, `address`, `phone`)
  select max(id)+1, m_name, m_last, addres, mphone
  from seq;
  
  END
  </code></pre>
  
  <p>This is my trigger:</p>
  
  <pre><code>USE `dbName`;
  DELIMITER $$
  
  CREATE DEFINER=`dbName`@`%` TRIGGER 
      guidesUpdate
  AFTER INSERT ON
      guides
  FOR EACH ROW
      BEGIN
          INSERT INTO seq VALUES ();
      END
  </code></pre>
  
  <p>when I run</p>
  
  <pre><code>call insertGuide('a'  ,'aa' ,'aaa' ,'12333')
  </code></pre>
  
  <p>it returns an error:</p>
  
  <blockquote>
    <p>Error Code: 1442. Can't update table 'seq' in stored function/trigger
    because it is already used by statement which invoked this stored
    function/trigger.</p>
  </blockquote>
  
  <p>Can I do something about it?</p>