title: MYSQL TRIGGER with DECLARE value
body: <p>I want to set value using declare on trigger. The trigger is as follow:</p>
  
  <pre><code>CREATE DEFINER=`root`@`localhost` TRIGGER `update_queue_after_insert` AFTER INSERT ON `encounter_note` FOR EACH ROW DECLARE is_exist INT;
    SET is_exist = ( SELECT count(*) FROM practice_last_updated_module WHERE practice_id = NEW.practice_id );
  
  IF NEW.enc_source = 'OP' THEN
  UPDATE practice_queue_list PQL SET
  PQL.vital_check = IF (NEW.vs_weight &lt;&gt; 0 OR NEW.vs_height &lt;&gt; 0 OR NEW.  vs_temperature &lt;&gt; 0 OR LENGTH(NEW.vs_blood_pressure) &gt; 0 &lt;&gt; NEW.vs_pulse &lt;&gt; 0 OR NEW.vs_respiration &lt;&gt; 0, 1, 0)
  WHERE PQL.encounter_id = NEW.id AND PQL.practice_place_id = NEW.practice_id;
  END IF;
  
  IF is_exist &gt; 0 THEN
        UPDATE practice_last_updated_module SET encounter = UNIX_TIMESTAMP(NOW()) where practice_id = NEW.practice_id;
  ELSE:
      INSERT INTO practice_last_updated_module (practice_id, encounter) VALUES (NEW.practice_id, UNIX_TIMESTAMP(NOW()));
  END IF;"
  </code></pre>
  
  <p>But it returns error on saving</p>
  
  <blockquote>
    <p>The following query has failed: "CREATE DEFINER=<code>root</code>@<code>localhost</code>
    TRIGGER <code>update_queue_after_insert</code> AFTER INSERT ON <code>encounter_note</code>
    FOR EACH ROW DECLARE is_exist INT; SET is_exist = ( SELECT count(*)
    FROM practice_last_updated_module WHERE</p>
  </blockquote>
  
  <p>What's wrong with the statement? </p>