Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

CV() in Model clause

PawanAgarwalAug 13 2013 — edited Aug 13 2013

Hi,

Although this query returns 6 rows of data (2 rows having data, and rest of the rows are having NULL values), where as my requirement is to to get the following output:

RUN_SEQUSAGE_PERIOD_START_DATE_DUSAGE_PERIOD_END_DATE_D
101-Jan-1330-Jan-13
231-Jan-1301-Mar-13
302-Mar-1331-Mar-13
401-Apr-1330-Apr-13
501-May-1330-May-13
631-May-1329-Jun-13

select RUN_SEQ, USAGE_PERIOD_START_DATE_D, USAGE_PERIOD_END_DATE_D

  from dual

model

   dimension by (1 as idx)

       MEASURES (

        1 as RUN_SEQ,

        TO_DATE('20130101','YYYYMMDD') AS USAGE_PERIOD_START_DATE_D,

        TO_DATE('20130101','YYYYMMDD')+29 AS USAGE_PERIOD_END_DATE_D

        )

   rules upsert all (

      RUN_SEQ[for idx from 2 to 6 increment 1] = RUN_SEQ[cv()-1]+1,

      USAGE_PERIOD_START_DATE_D[for idx from 2 to 6 increment 1] = USAGE_PERIOD_END_DATE_D[cv()-1]+1,

      USAGE_PERIOD_END_DATE_D[for idx from 2 to 6 increment 1] = USAGE_PERIOD_START_DATE_D[cv()]+29

   )

order by idx;

Could anyone please suggest where am I going wrong.

Thanks & Regards,

Pawan

This post has been answered by BrendanP on Aug 13 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 10 2013
Added on Aug 13 2013
7 comments
331 views