title: how to declare variable in mysql trigger
body: <p>this is my trigger</p>
  
  <pre><code>CREATE TRIGGER proximo_pago 
  AFTER INSERT ON pago FOR EACH ROW
  BEGIN
      DECLARE max_orden integer;
      DECLARE num_lote =NEW.lote;
          BEGIN
              SET max_orden = (SELECT MAX(orden) FROM PAGO WHERE LOTE=num_lote);
              SELECT max_orden INTO : NEW.orden from dual;
              END
  END
  </code></pre>
  
  <p>and the error</p>
  
  <p>Error
  SQL query:</p>
  
  <pre><code>CREATE TRIGGER proximo_pago 
  AFTER INSERT ON pago FOR EACH ROW
  BEGIN
      DECLARE max_orden integer;
  </code></pre>
  
  <p>MySQL said: Documentation</p>
  
  <blockquote>
    <p>#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 4 </p>
  </blockquote>