title: MySQL: Getting a return code when calling a stored procedure within another stored procedure?
body: <p>You have 2 MySQL stored procedures, both that select return codes at the end. You need to call 1 stored procedure within another, and get its return code. Is this possible?</p>
  
  <p>Proc1:</p>
  
  <pre><code>CREATE PROCEDURE (IN...)
  BEGIN
  DECLARE ret_code
  ...UPDATE SOMETHING....
  SELECT ret_code as return_code from dual;
  END
  </code></pre>
  
  <p>Proc2:</p>
  
  <pre><code>CREATE PROCEDURE (IN...)
  BEGIN
  DECLARE returnVal
  if(conditional true)
      ..Update something else..
      Set returnVal = x;
  else
      call proc1(var1,...)
      Set returnVal = (ret_code obtained from proc1)
  end if
  select returnVal;
  END
  </code></pre>
  
  <p>When calling proc1 within proc2, how can I get that ret_code that's selected at the end of proc1 within proc2?</p>