title: mysql stored procedure with INTO OUTFILE
body: <p>I have a mysql stored procedure where I want to do two things
  1. query a table and return the result as normal result set.
  2. iterate through the result set and create a formatted text file from the procedure itself.</p>
  
  <p>I looked at INTO OUTFILE, but it seems INTO OUTFILE writes the result raw to the specified file and also if we use INTO OUTFILE resultset will be empty. Seems we can't have both.</p>
  
  <p>Here is my sample SP</p>
  
  <pre><code>DELIMITER $$
  
  CREATE DEFINER=`root`@`localhost` PROCEDURE `getdeals`()
  BEGIN
  
  select * INTO OUTFILE '/Users/tuser/sql/out.txt' from deals;
  
  END
  </code></pre>
  
  <p>Any thoughts ?
  Thanks
  Prem</p>