title: INSERT INTO statement after CASE WHEN in Oracle SQL
body: <p>A table named ROUTINE r does have the following attributes: ID (NUMBER), NAME (VARCHAR2(40)), MONDAY_YN (NUMBER(1,0)), TUESDAY_YN (NUMBER(1,0)),..., SUNDAY_YN (NUMBER(1,0)), in which each routine has an ID, a name and also a representation of weekdays it is outstanding (e.g. MONDAY_YN=1) or not (MONDAY_YN=0). Additionally to check if a routine is successfully done on a specific date, there is a second table named ROUTINE_CHECKLIST rc that consists of the routine ID (Foreign key connection with table ROUTINE r), a date and a status (0 for outstanding, 1 for done).</p>
  <p>Now, I want to insert data into the table ROUTINE_CHECKLIST with following SQL which works perfectly fine to insert the next 3 mondays for a specified Routine.</p>
  <pre><code>insert into EBA_MTGMIN_ROUTINE_CHECKLIST (ROUTINE_ID, routine_date, done_yn)
  select ID, next_day ( sysdate, 'monday' ) + ( ( level - 1 ) * 7 ), 0
  from EBA_MTGMIN_ROUTINE r
  where r.ID = 4711
  connect by level &lt;= 3;
  </code></pre>
  <p>Depending on each weekday attribute in table ROUTINE a case statement should be used, that checks if r.MONDAY_YN = 1 then insert the next 3 mondays, if r.TUESDAY_YN = 1 then insert next 3 tuesdays, etc. To match these requirements I tried to make use of the SELECT CASE WHEN clause in the SQL statement as follows:</p>
  <pre><code>SELECT ro.MONDAY_YN,  
  SELECT CASE WHEN ro.MONDAY_YN=1 THEN (insert into EBA_MTGMIN_ROUTINE_CHECKLIST (routine_date, done_yn, ROUTINE_ID)
  select distinct next_day ( sysdate, 'monday' ) + ( ( level - 1 ) * 7 ), 0, r.ID
  from EBA_MTGMIN_ROUTINE r
  where r.ID = 4711
  connect by level &lt;= 3)
  END
  from EBA_MTGMIN_ROUTINE ro
  where ro.ID = 4711;
  </code></pre>
  <p>That statement does not execute as expected, but results in ORA-00936: missing expression error. What would be an elegent way to extend the insert statement in Oracle SQL or PL/SQL to fill the table ROUTINE_CHECKLIST?</p>