title: Dynamic UPDATE statement to update values in columns returned by a previous SELECT
body: <p>In essence, what I want to do is:</p>
  
  <ul>
  <li>find all tables and their columns that match a specific query,</li>
  <li>update values in these columns.</li>
  </ul>
  
  <p>So say I have something like</p>
  
  <pre><code>SELECT COLUMN_NAME, TABLE_NAME, TABLE_SCHEMA
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE
      (
        TABLE_SCHEMA = 'PUBLIC'
      ) AND (
        COLUMN_NAME LIKE '%SOMETHING%'
        OR COLUMN_NAME LIKE '%SOMETHINGELSE%'
      ) AND (
        DATA_TYPE = 'BIGINT' OR
        DATA_TYPE = 'TINYINT' OR
        DATA_TYPE = 'SMALLINT' OR
        DATA_TYPE = 'INTEGER'
      )
  </code></pre>
  
  <p>Or for Oracle something like:</p>
  
  <pre><code>SELECT COLUMN_NAME, TABLE_NAME
    FROM USER_TAB_COLS
    WHERE
      (
        COLUMN_NAME LIKE '%SOMETHING%'
        OR COLUMN_NAME LIKE '%SOMETHINGELSE%'
      ) AND
      DATA_TYPE IN ('NUMBER')
  </code></pre>
  
  <p>I want to then do an <code>UPDATE</code> on all resulting columns similar to:</p>
  
  <pre><code>UPDATE _RESULTING_COLUMN_NAMES_HERE_THEORETICALLY_
    SET
      _SINGLE_COLUMN_NAME_ = _SOME_NEW_VALUE_
    WHERE _SINGLE_COLUMN_NAME_ = _SOME_OLD_VALUE_;
  </code></pre>
  
  <p>Well obviously that does not work or even exist, but I hope you understand what I want to achieve.</p>
  
  <p>I could see a way where you generate an <code>UPDATE</code> statement for each matching table from the <code>SELECT</code> resultset, but I don't really see how to achieve this.</p>
  
  <p>To make things more fun, I'd need to do that for a list of old_value to new_value transformations.</p>
  
  <p>Any ideas are welcome.</p>
  
  <p>I am trying to have this work on HSQLDB and Oracle as my 2 requirements, but supporting additional platforms would be a pretty good bonus.</p>