title: Mysql trigger write data to file
body: <p>There is a way to write data to disk from a trigger into a file? The file name need to be created dynamically.</p>
  
  <p>Using PREPARE will not work on trigger.
  e.g. </p>
  
  <pre><code>SET @Query1 = 
  CONCAT("SELECT ",'data'," INTO DUMPFILE 'c:/temp/", UNIX_TIMESTAMP(),"-",RAND(), ".txt'");
  PREPARE statementCreate FROM @Query1;
  EXECUTE statementCreate;
  DEALLOCATE PREPARE statementCreate;
  </code></pre>
  
  <p>Note: data is a variable</p>
  
  <p>Or there is other solution to append to the same file from the trigger? Will work that too.</p>