title: Is it possible to use a CASE WHEN expression in a FROM clause in Oracle?
body: <p><strong>Context</strong></p>
  
  <p>Using Oracle 12c Standard Edition (whose licensing model does not allow to use Table Partitions).</p>
  
  <p><strong>Goal</strong></p>
  
  <p>Use that inside a trigger to dispatch rows dynamically to different tables.</p>
  
  <p><strong>Example</strong></p>
  
  <pre><code>CREATE OR REPLACE trigger TRG_DISPATCH
    instead of insert or update on MY_VIEW
    for each row
  
  DECLARE
    partition_id SIMPLE_INTEGER ;
  
  BEGIN
    partition_id := 1 ;
  
    insert into
      case
        when partition_id = 1 then "my_table_1"
        when partition_id = 2 then "my_table_2"
      end ( "id", "code", "msg" )
    values
      ( :new."id", :new."code", :new."msg" )
    ;
  END ;
  /
  </code></pre>
  
  <p><strong>Note</strong>
  I <em>already</em> know <a href="https://stackoverflow.com/questions/646334/is-it-possible-to-use-a-case-statement-in-a-sql-from-clause">this cannot be achieved using Microsoft SQL Server 2005</a> but all RDBMS are not equal.</p>