title: Working with hex numbers in MySQL
body: <p>I have a stored procedure that needs to convert hexadecimal numbers to their decimal equivalent.  I've read the documentation for the UNHEX() function, but it is returning a binary value.  What I'm wanting to do is something like this:</p>
  
  <pre><code>CREATE PROCEDURE foo( hex_val VARCHAR(10) )
  BEGIN
      DECLARE dec_val INTEGER;
  
      SET dec_val = UNHEX( hex_val );
  
      -- Do something with the decimal value
      select dec_val;
  END
  </code></pre>
  
  <p>What am I missing?  How can I convert the UNHEX()'d value to a unsigned integer?</p>