title: Why part of a trigger is executed before the rest of it?
body: <p>I have a trigger like this:</p>
  
  <pre><code>DECLARE v1 VARCHAR(4);
  and so on declaration
  ...
  
  IF LENGTH(new.ID) &lt; 11 OR new.ID= '' THEN         
          RAISERROR 23004 'Too short!';
  ENDIF;
  
  SET v1 = substring(new.ID,1,3);
  and more action on v1...
  </code></pre>
  
  <p>What I want to say, is that the <code>set</code> part is being executed before the <code>if</code> and I don't know why. Do You have an idea how to fix it?</p>
  
  <p>Thanks in advance</p>