rajesh@ORA11G> drop table t purge;
rajesh@ORA11G> create table t (instance_number int, volume int, start_dt date, end_dt date);
rajesh@ORA11G> insert into t values (1, 100, to_date('01-Jan-2014','dd-mon-yyyy'), to_date('31-JAN-2014','dd-mon-yyyy') );
rajesh@ORA11G> insert into t values (1, 105, to_date('01-FEB-2014','dd-mon-yyyy'), to_date('31-MAR-2014','dd-mon-yyyy') );
rajesh@ORA11G> insert into t values (1, 102, to_date('01-APR-2014','dd-mon-yyyy'), to_date('30-APR-2014','dd-mon-yyyy') );
rajesh@ORA11G> commit;
rajesh@ORA11G> set feedback on
rajesh@ORA11G>
rajesh@ORA11G> select instance_number,volume, to_date(x,'j') dts
2 from t
3 where volume = 100
4 model return updated rows
5 partition by (instance_number,volume)
6 dimension by (1 x)
7 measures( cast(null as date) new_dt, end_dt,start_dt)
8 rules
9 ( new_dt[ for x from to_number( to_char( start_dt[1] ,'j') )
10 to to_number( to_char( end_dt[1] ,'j') ) increment 1 ] = sysdate
11 )
12 /
INSTANCE_NUMBER VOLUME DTS
--------------- ---------- -----------------------
1 100 01-JAN-2014 12:00:00 AM
1 100 02-JAN-2014 12:00:00 AM
1 100 03-JAN-2014 12:00:00 AM
1 100 04-JAN-2014 12:00:00 AM
1 100 05-JAN-2014 12:00:00 AM
1 100 06-JAN-2014 12:00:00 AM
1 100 07-JAN-2014 12:00:00 AM
1 100 08-JAN-2014 12:00:00 AM
1 100 09-JAN-2014 12:00:00 AM
1 100 10-JAN-2014 12:00:00 AM
1 100 11-JAN-2014 12:00:00 AM
1 100 12-JAN-2014 12:00:00 AM
1 100 13-JAN-2014 12:00:00 AM
1 100 14-JAN-2014 12:00:00 AM
1 100 15-JAN-2014 12:00:00 AM
1 100 16-JAN-2014 12:00:00 AM
1 100 17-JAN-2014 12:00:00 AM
1 100 18-JAN-2014 12:00:00 AM
1 100 19-JAN-2014 12:00:00 AM
1 100 20-JAN-2014 12:00:00 AM
1 100 21-JAN-2014 12:00:00 AM
1 100 22-JAN-2014 12:00:00 AM
1 100 23-JAN-2014 12:00:00 AM
1 100 24-JAN-2014 12:00:00 AM
1 100 25-JAN-2014 12:00:00 AM
1 100 26-JAN-2014 12:00:00 AM
1 100 27-JAN-2014 12:00:00 AM
1 100 28-JAN-2014 12:00:00 AM
1 100 29-JAN-2014 12:00:00 AM
1 100 30-JAN-2014 12:00:00 AM
1 100 31-JAN-2014 12:00:00 AM
31 rows selected.
rajesh@ORA11G> set autotrace traceonly explain
rajesh@ORA11G> /
Execution Plan
----------------------------------------------------------
Plan hash value: 4004708133
---------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 23 | 3 (0)| 00:00:01 |
| 1 | SQL MODEL ORDERED | | 1 | 23 | | |
|* 2 | TABLE ACCESS FULL| T | 1 | 23 | 3 (0)| 00:00:01 |
---------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter("VOLUME"=100)
rajesh@ORA11G> set autotrace off
rajesh@ORA11G>Feel free to comment out the "Where" clause to run it for the entire result sets.