Inserting into a base table of a materialized view takes lot of time.......

Dear All,
I have created a materialized view which refreshes on commit.materialized view is enabled query rewrite.I have created a materialized view log on the base table also While inserting into the base table it takes lot of time................Can u please tell me why?

Dear Rahul,
Here is my materialized view..........
create materialized view mv_test on prebuilt table refresh force on commit
enable query rewrite as
SELECT P.PID,
SUM(HH_REGD) AS HH_REGD,
SUM(INPRO_WORKS) AS INPRO_WORKS,
SUM(COMP_WORKS) AS COMP_WORKS,
SUM(SKILL_WAGE) AS SKILL_WAGE,
SUM(UN_SKILL_WAGE) AS UN_SKILL_WAGE,
SUM(WAGE_ADVANCE) AS WAGE_ADVANCE,
SUM(MAT_AMT) AS MAT_AMT,
SUM(DAYS) AS DAYS,
P.INYYYYMM,P.FIN_YEAR
FROM PROG_MONTHLY P
WHERE SUBSTR(PID,5,2)<>'PP'
GROUP BY PID,P.INYYYYMM,P.FIN_YEAR;
Please help me if query enable rewrite does any performance degradation......
Thanks & Regards
Kris

Similar Messages

  • How to insert into two differents tables at the same time

    Hi
    I'm newer using JDev, (version 3.1.1.2 cause the OAS seems to support just the JSP 1.0)
    and I want to insert into two differents tables at the same time using one view.
    How can I do that ?
    TIA
    Edgar

    Oracle 8i supports 'INSTEAD OF' triggers on object views so you could use a process similar to the following:
    1. Create an object view that joins your two tables. 'CREATE OR REPLACE VIEW test AS SELECT d.deptno, d.deptname, e.empname FROM DEPT d, EMP E'.
    2. Create an INSTEAD OF trigger on the view.
    3. Put code in the trigger that looks at the :NEW values being processed and determines which columns should be used to INSERT or UPDATE for each table. Crude pseudo-code might be:
    IF :NEW.deptno NOT IN (SELECT deptno FROM DEPT) THEN
    INSERT INTO dept VALUES(:NEW.deptno, :NEW.deptname);
    INSERT INTO emp VALUES (:NEW.deptno, :NEW.empname);
    ELSE
    IF :NEW.deptname IS NOT NULL THEN
    UPDATE dept SET deptname = :NEW.deptname
    WHERE deptno = :NEW.deptno;
    END IF;
    IF :NEW.empname IS NOT NULL THEN
    UPDATE emp SET empname = :NEW.empname
    WHERE deptno = :NEW.deptno;
    Try something along those lines.
    null

  • Multi-table mapping is not inserting into the primary table first.

    I have an inheritance mapping where the children are mapped to the parent table oids with the "Multi-Table Info" tab.
    One of children is not inserting properly. Its insert is attempting to insert into one of the tables from the "Additional Tables" of "Multi-Table Info" instead of the primary table that it is mapped to.
    The other children insert correctly. This child is not much different from those.
    I looked through the forums, but found nothing similiar.

    I would expect the Children to be inserted into both the primary table and the Additional Table? Is the object in question inserted into the primary table at all? Is the problem that it is being inserted into the Additional Table first? If it is, are the primary key names different? Is it a foreign key relationship?
    If the object in question has no fields in the additional table is it mapped to the additional table? (it should not be)
    Perhaps providing the deployment XML will help determine the problem,
    --Gordon                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to select data from 3rd row of Excel to insert into Sql server table using ssis

    Hi,
    Iam having Excel files with headers in first two rows , i want two skip that two rows and select data from 3rd row to insert into Sql Server table using ssis.3rd row is having column names.

                                                         CUSTOMER DETAILS
                         REGION
    COL1        COL2        COL3       COL4           COL5          COL6          COL7
           COL8          COL9          COL10            COL11      
    1            XXX            yyyy         zzzz
    2            XXX            yyyy        zzzzz
    3           XXX            yyyy          zzzzz
    4          XXX             yyyy          zzzzz
    First two rows having cells merged and with headings in excel , i want two skip the first two rows and select the data from 3rd row and insert into sql server using ssis
    Set range within Excel command as per below
    See
    http://www.joellipman.com/articles/microsoft/sql-server/ssis/646-ssis-skip-rows-in-excel-source-file.html
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Nologging direct-path insert into an indexed table

    Hello,
    Does anyone have an idea how I can suppress generation of undo logs for direct-path insert into an indexed table on 11.2.0.1.0:
    CREATE TABLE TBL(ID NUMBER) NOLOGGING;
    CREATE INDEX IDX ON TBL(ID) NOLOGGING;
    INSERT /*+ APPEND */ INTO TBL SELECT /*+ APPEND */ ROWNUM FROM ...; -- Source table has 400,000,000+ rows
    Regards,
    Angel Tsankov

    Pl do not post duplicates - Why does Oracle not use direct-path insert when instructed to do so - pl continue the discussion in your original thread

  • XSQL Insert into Schema based Table

    Hi,
    I am struggling with this one:
    My test XML is well formed:
    <?xml version="1.0"?>
    <SC_ESP>
    <ResultSet>
         <ApplicationID>App0001</ApplicationID>
         <Reason>Sucess</Reason>
    </ResultSet>
    </SC_ESP>
    Whan I try to POST this XML data via the XSQL Servlet
    I get the following error:
    "Character '$' is not allowed in a XML tag name."
    Anyone (Mark ?) know what it means ?
    Thanks
    Martin

    Hello Mark,
    I don't know which time zone you are in but thanks for the very prompt replies.
    All I am trying to with this test is provide an XML input test facility via HTTP. The users are supposed to paste the XML into a TextAre using their browser and have that data inserted into the corresponding Table(s) via the XSQL servlet.
    The XML schema have already been registered but I note from your other reply that I have not added the annotation xdb:storeVarrayAsTable="true" to the schema tags.
    It is worth noting that the whole thing works if I create a simple table that is NOT related to an XML Shema.
    You say that you have not had to use the XSQl Servlet. Would you care to say what approach you would use for the above requirement. Shall I set about writing my own Servlet to do this.

  • How to execute a Java method when row inserted into a database table?

    I have the need to fire off a java method when a row is inserted into a database table. I am unfortunately working with MySQL which just recently supported triggers but these new triggers can not execute a Java application on any event.
    What I am looking for is an event driven approach such that when a row is inserted into a specific table I can fire off a java method (sitting in a tomcat container) that will take the contents and send it to a web service.
    It has been mentioned that JMS may have the ability to poll and monitor a database table. Just wondering if anyone could point me in the right direction.
    thanks
    JavaTek

    A service handler might be the right way to run some code at the end of a service call (another way would be to make use of filters).
    First, make sure your static table is merged with ServiceHandlers.
    Secondary, change your custom method name into one that is not already in the service definition of COLLECTION_COPY_LOT (preferably a unique method name like collectionCopyLotLastAction that describes its purpose) and remove the following line from your code:
    m_service.doCodeEx("",this);Now create a service definition for COLLECTION_COPY_LOT in your custom component based on the original COLLECTION_COPY_LOT (copy paste from the original service definition) and add you own method collectionCopyLotLastAction as the last step in the service. Play with the load order to make sure CS is using your service definition of COLLECTION_COPY_LOT instead of the original.
    regards,
    Fabian

  • Inserts into Global Temporary Table

    I'm working on using a global temporary table in one of my apps. I have a small test run here to isolate the problem. It simply creates the global temporary table, inserts a row, commits and then does a select to see if the insert worked. No data shows in the table when running this. I don't know much about global temp tables, so any help would be appreciated.
    CREATE GLOBAL TEMPORARY TABLE AGENT_SILO.AS_TEMP_VALIDATE (
    SBI_EMPLOYEE_ID NUMBER,
    CURRENT_FLAG char(1),
    EFFECTIVE_START date,
    EFFECTIVE_END date
    ) ON COMMIT DELETE ROWS;
    INSERT INTO AGENT_SILO.AS_TEMP_VALIDATE(SBI_EMPLOYEE_ID, CURRENT_FLAG, EFFECTIVE_START, EFFECTIVE_END)
    VALUES(0, '', SYSDATE, SYSDATE);
    commit;
    SELECT * FROM AGENT_SILO.AS_TEMP_VALIDATE;

    So I wonder what else I'm doing wrong that's really obvious. Here's what i'm trying to accomplish and maybe there's a better way of going about it.
    I have a trigger that is supposed to do some validation before the insert is allowed to go through. So here's my approach. I have a trigger fired when there's an insert into the AS_Employee_history table. This passes some of the fields from this insert into a proc (the id, a flag and a couple of dates). Within the proc, i create a global temp table, insert these passed values into the temp table. Then I have a cursor to basically copy the rows from the as_employee_history table that have the same id. Then I can do some selects on the temp table to see if it passes the validation.
    I have outputs throughout for debugging and it gets to right after the inserts into the temp table, then the rest of the code doesn't appear to be executed. So it looks like it's failing at the execution of select statements on the temp table. Anything else obvious that I"m missing here?
    Here's my proc.
    PROCEDURE "PAS_VALIDATE" (STATUS OUT VARCHAR2, v_status OUT BOOLEAN, NEW_SBI_EMPLOYEE_ID IN NUMBER,
    NEW_CURRENT_FLAG IN CHAR, NEW_EFFECTIVE_START IN DATE,
    NEW_EFFECTIVE_END IN DATE)
    IS
    v_prev_effective_end date;
    v_flag_count number;
    v_flag_count_date number;
    --variables to store dynamic sql returns
    v_sql_flag_count_date varchar2(255);
    v_sql_flag_count varchar2(255);
    v_sql_prev_eff_end varchar2(255);
    cursor c_row is
    select * from AGENT_SILO.AS_EMPLOYEE_HISTORY EMP
    where (EMP.SBI_EMPLOYEE_ID = NEW_SBI_EMPLOYEE_ID);
    r_row c_row%ROWTYPE;
    BEGIN
    Status := 'Started';
    v_status := true;
    DBMS_OUTPUT.PUT_LINE('Creating temporary table...');
    execute immediate 'CREATE GLOBAL TEMPORARY TABLE AGENT_SILO.AS_TEMP_VALIDATE (
    SBI_EMPLOYEE_ID NUMBER,
    CURRENT_FLAG char(1),
    EFFECTIVE_START date,
    EFFECTIVE_END date
    ) ON COMMIT PRESERVE ROWS';
         DBMS_OUTPUT.PUT_LINE('Validating the data...');
         --DBMS_OUTPUT.PUT_LINE('Inserting submitted row into temp table');
    --Insert the new row being submitted from user into the temp table
    execute immediate 'INSERT INTO AGENT_SILO.AS_TEMP_VALIDATE(SBI_EMPLOYEE_ID, CURRENT_FLAG, EFFECTIVE_START, EFFECTIVE_END)
    VALUES(' || NEW_SBI_EMPLOYEE_ID || ',
    ''' || NEW_CURRENT_FLAG || ''',
    to_date(''' || to_char(NEW_EFFECTIVE_START, 'mm/dd/yyyy hh:mi:ss') || ''', ''mm/dd/yyyy hh:mi:ss''),
    to_date(''' || to_char(NEW_EFFECTIVE_END, 'mm/dd/yyyy hh:mi:ss') || ''', ''mm/dd/yyyy hh:mi:ss''))';
    --Insert the other rows to we end up with a subset of the employee history table
    --with only rows that match the sbi_employee_id of the submitted row
         --DBMS_OUTPUT.PUT_LINE('Inserting into temp table...');
    open c_row;
    loop
    fetch c_row into r_row;
    exit when c_row%NOTFOUND;
    execute immediate 'INSERT INTO AGENT_SILO.AS_TEMP_VALIDATE(SBI_EMPLOYEE_ID, CURRENT_FLAG, EFFECTIVE_START, EFFECTIVE_END)
    VALUES(' || r_row.SBI_EMPLOYEE_ID || ',
    ''' || r_row.CURRENT_FLAG || ''',
    to_date(''' || to_char(r_row.EFFECTIVE_START, 'mm/dd/yyyy hh:mi:ss') || ''', ''mm/dd/yyyy hh:mi:ss''),
    to_date(''' || to_char(r_row.EFFECTIVE_END, 'mm/dd/yyyy hh:mi:ss') || ''', ''mm/dd/yyyy hh:mi:ss''))';
    end loop;
    close c_row;
    DBMS_OUTPUT.PUT_LINE('After inserts');
    -----Store queries to determine values for validation--------------------------
    v_sql_prev_eff_end := 'SELECT to_char(max(effective_end), ''dd-mon-yy'')
    FROM AGENT_SILO.AS_TEMP_VALIDATE
    where to_char(EFFECTIVE_END, ''dd-mon-yy'') != ''31-dec-99'' AND
    SBI_EMPLOYEE_ID = NEW_SBI_EMPLOYEE_ID';
    --Find the largest effective_end, besides the 9999 value
    execute immediate v_sql_prev_eff_end into v_prev_effective_end;
    DBMS_OUTPUT.PUT_LINE('The highest previous end date: ' || v_prev_effective_end);
    --...........Validation testing...........
    execute immediate 'DROP TABLE AGENT_SILO.AS_TEMP_VALIDATE'; --Drop temp table
    DBMS_OUTPUT.PUT_LINE('Validation Procedure Complete');
    COMMIT;
    status:='Success';
    EXCEPTION
    When Others Then
    ROLLBACK;
    Status := SQLERRM;
    END;
    Thanks a bunch for helping a noob out.

  • ORA-01776: cannot modify more than one base table through a join view

    I have created EO based on a database view than consists of two tables, and only one is updateable.
    When I try to update a row using EO, I got a following message: "ORA-01776-cannot modify more than one base table through a join view"
    In Forms, this issue is resolved by setting "Query Only" property of non-updateable items to "True".
    Is it possible to do something like that in ADF BC?
    Thanks

    Thanks for answer.
    When I set "updateable" property to "Never", that attribute is protected from any change.
    I'm sorry for incomplete usecase.
    I have set up a list of value on that attribute, because it is a lookup field for another table and I need to get an ID from that table.
    Basically, I need that attribute to be updateble for BC, but not for database.
    Edited by: MarioK on Oct 13, 2011 9:28 AM

  • Cannot modify more than one base table through a join view

    hi guys, my current problem is that i have a datablock based on a view, now all the fields bar 1 are updateable, but this one field that is obtained through a join is displayed, the user can enter data in this field which then pupulates other fields which are required, but this specific field should not be updated. Is there an option to state this as i keep getting the error:
    cannot modify more than one base table through a join view
    Any help would be greatly appreciated, thanks.

    the user can enter data in this field which then pupulates other fields So, using the value of "this field" you then query the rest of the fields? Can you show us the code you use to populate the rest of the fields?
    but this specific field should not be updatedHave you tried setting the "Query Only" property of the field to "Yes" and the other DML properties (Ins, Upd, Del) to No?
    Also, what is your Forms version?
    Thanks,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • Table Operator Vs Materialized View Operator

    Hi All,
    Could you please give the differences between Table Operator and Materialized view Operator in Oracle Warehouse Builder 11g.
    Regards,
    Subbu

    Below an extract of my notes of the Materialized view. The complete notes are here :
    http://gerardnico.com/wiki/dw/aggregate_table
    =====Notes=====
    Materialized views are the equivalent of a summary table. (Materialized views can be also use as replica).
    In a olap approach, each of the elements of a dimension could be summarized using a hierarchy.
    The end user queries the tables and views in the database. The query rewrite mechanism in a database automatically rewrites the SQL query to use this summary tables.
    This mechanism reduces response time for returning results from the query. Materialized views within the data warehouse are transparent to the end user or to the database application.
    This is relatively straightforward and is answered in a single word - performance. By calculating the answers to the really hard questions up front (and once only), we will greatly reduce the load on the machine, We will experience:
    * Less physical reads - There is less data to scan through.
    * Less writes - We will not be sorting/aggregating as frequently.
    * Decreased CPU consumption - We will not be calculating aggregates and functions on the data, as we will have already done that.
    * Markedly faster response times - Our queries will return incredibly quickly when a summary is used, as opposed to the details. This will be a function of the amount of work we can avoid by using the materialized view, but many orders of magnitude is not out of the question.
    Materialized views will increase your need for one resource - more permanently allocated disk. We need extra storage space to accommodate the materialized views, of course, but for the price of a little extra disk space, we can reap a lot of benefit.
    Also notice that we may have created a materialized view, but when we ANALYZE, we are analyzing a table. A materialized view creates a real table, and this table may be indexed, analyzed, and so on.
    Success
    Nico

  • Query from source table takes lots of time

    I have to load data from an Oracle table which has millions of records. The loading knowledge module I am using is 'lkm sql to oracle'.
    I see that the query from the source database takes lot of time and doing a full table scan where as it supposed to be using an index.
    I dont have any lkm with 'lkm oracle to oracle'. Some how I need to add a hint to this source query. How I can do this?

    This LKM is not indicated to large volume of data, try to use LKM Oracle to Oracle (DBLINK), see ODI KMs documentation for more information.
    Related to HINTS you can add this with KM options, see that some Oracle ODI11g new KMs already have some options to do it, so you can put the hint on interface options of KM or define the temp index on the interface

  • Insert records into non base table

    Hi
    I would like to insert records into a table when a button is clicked. The table is a non base table. I am trying to save records displayed in a form into a history table which is not part of the form. I am using the following code stored in a program unit then called when the button is pressed. It doesn't generate any error but the records are not inserted. Can anyone please help.
    hist_id := 1;
    cust_name := :CUSTOMER.cust_name;
    loan_date := :LOAN.loan_date;
    return_date := LOAN.return_date;
    FORMS_DDL('INSERT INTO LOAN_HISTORY VALUES'||hist_id||','||cust_name||','||loan_date||','||return_date);

    Why do you need forms_ddl built in for a DML statement to be used in form?
    U can directly use insert.
    hist_id := 1;
    cust_name := :CUSTOMER.cust_name;
    loan_date := :LOAN.loan_date;
    return_date := LOAN.return_date;
    INSERT INTO LOAN_HISTORY VALUES (hist_id,cust_name,loan_date,return_date);
    It should work perfectly.

  • Error insert data over db link in table covered by materialized view

    Hello together,
    following problem:
    I got a table called LOCATION_INFO which is defined:
    create table LOCATION_INFO
    LOCATION_ID VARCHAR2(40) not null,
    PLANT VARCHAR2(4) not null,
    PRODUCT VARCHAR2(3),
    AREA VARCHAR2(1),
    LINE NUMBER(10),
    STATION NUMBER(10),
    STATINDEX NUMBER(10),
    FU NUMBER(10),
    WP NUMBER(10),
    TP NUMBER(10),
    LOCATION_LEVEL NUMBER(1) not null,
    LOCATION_PARENT_ID VARCHAR2(40),
    TIME_STAMP TIMESTAMP(6) WITH TIME ZONE not null
    I try to load data over PL/SQL procedure from another database using database link:
    INSERT INTO LOCATION_INFO
    (LOCATION_ID,
    PLANT,
    PRODUCT,
    AREA,
    LINE,
    STATION,
    STATINDEX,
    FU,
    WP,
    TP,
    LOCATION_LEVEL,
    LOCATION_PARENT_ID,
    TIME_STAMP)
    SELECT LOCATION_ID,
    PLANT,
    PRODUCT,
    AREA,
    LINE,
    STATION,
    STATINDEX,
    FU,
    WP,
    TP,
    LOCATION_LEVEL,
    LOCATION_PARENT_ID,
    GetUTCDateTime(TIME_STAMP) AS time_Stamp
    FROM LOCATION_INFO@SOURCE_MMPDDB
    WHERE ROWNUM < 100;
    This works fine (If i do select count(*) from location_info the data is present) but if set a commit
    ORA-00603 appears and the session is terminated.
    The point is i got a materialized view MVIEW_LOCATIONS in another schema in the database reading the data from my table location_info and a corresponding MVIEWLOG.
    create table MLOG$_LOCATION_INFO
    LOCATION_ID VARCHAR2(40),
    SNAPTIME$$ DATE,
    DMLTYPE$$ VARCHAR2(1),
    OLD_NEW$$ VARCHAR2(1),
    CHANGE_VECTOR$$ RAW(255)
    CREATE MATERIALIZED VIEW MVIEW_LOCATIONS
    REFRESH FAST ON COMMIT
    ENABLE QUERY REWRITE
    AS
    SELECT "LOCATION_INFO"."LOCATION_ID" "LOCATION_ID","LOCATION_INFO"."PLANT" "PLANT","LOCATION_INFO"."PRODUCT" "PRODUCT","LOCATION_INFO"."AREA" "AREA","LOCATION_INFO"."LINE" "LINE","LOCATION_INFO"."STATION" "STATION","LOCATION_INFO"."STATINDEX" "STATINDEX","LOCATION_INFO"."FU" "FU","LOCATION_INFO"."WP" "WP","LOCATION_INFO"."TP" "TP","LOCATION_INFO"."LOCATION_LEVEL" "LOCATION_LEVEL","LOCATION_INFO"."LOCATION_PARENT_ID" "LOCATION_PARENT_ID","LOCATION_INFO"."TIME_STAMP" "TIME_STAMP" FROM "CP4MMPDNEW"."LOCATION_INFO" "LOCATION_INFO";
    What do I need to do to make the insert working properly without deleting my mviews?
    Can anyone help me?
    Thanks, Matthias

    Helllo,
    Can you change this on your Materialized View DDL:
    REFRESH FAST ON COMMITTo:
    REFRESH FAST ON DEMANDThen, if your INSERT and COMMIT works OK then, can you try:
    exec DBMS_MVIEW.REFRESH('MVIEW_LOCATIONS')

  • Adding 2 more rows to a select without inserting rows to base table

    hello all,
    i have a below simple select statement which is querying a table.
    select * from STUDY_SCHED_INTERVAL_TEMP
    where STUDY_KEY = 1063;
    but here is the situations. As you can see its returning 7 rows. But i need to add
    2 more rows..with everything else default value or what exist... except adding 2 more rows.
    i cannot insert into base table. I want my end results to increment by 2 days in
    measurement_date_Taken to 01-apr-09....so basically measurement_date_taken should
    end at study_end_Date...
    IS THAT EVEN POSSIBLE WITHOUT INSERTING ROWS INTO THE TABLE AND JUST PLAYIHY AROUND WITH
    THE SELECT STATEMENT??
    sorry if this is confusing...i am on 10.2.0.3
    Edited by: S2K on Aug 13, 2009 2:19 PM

    Well, I'm not sure if this query looks as good as my lawn, but seems to work anyway ;)
    I've used the 'simplified version', but the principle should work for your table to, S2K.
    As Frank already pointed out (and I stumbled upon it while clunging): you just select your already existing rows and union them with the 'missing records', you calculate the number of days you're 'missing' based on the study_end_date:
    MHO%xe> alter session set nls_date_language='AMERICAN';
    Sessie is gewijzigd.
    Verstreken: 00:00:00.01
    MHO%xe> with t as ( -- generating your data here, simplified by me due to cat and lawn
      2  select 1063 study_key
      3  ,      to_date('01-MAR-09', 'dd-mon-rr') phase_start_date
      4  ,      to_date('02-MAR-09', 'dd-mon-rr') measurement_date_taken
      5  ,      to_date('01-APR-09', 'dd-mon-rr') study_end_date
      6  from dual union all
      7  select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('04-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
      8  select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('09-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
      9  select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('14-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
    10  select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('19-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
    11  select 1063, to_date('22-MAR-09', 'dd-mon-rr') , to_date('23-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
    12  select 1063, to_date('22-MAR-09', 'dd-mon-rr') , to_date('30-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual
    13  ) -- actual query:
    14  select study_key
    15  ,      phase_start_date
    16  ,      measurement_date_taken
    17  ,      study_end_date
    18  from   t
    19  union all
    20  select study_key
    21  ,      phase_start_date
    22  ,      measurement_date_taken + level -- or rownum
    23  ,      study_end_date
    24  from ( select study_key
    25         ,      phase_start_date
    26         ,      measurement_date_taken
    27         ,      study_end_date
    28         ,      add_up
    29         from (
    30                select study_key
    31                ,      phase_start_date
    32                ,      measurement_date_taken
    33                ,      study_end_date
    34                ,      study_end_date - max(measurement_date_taken) over (partition by study_key
    35                                                                          order by measurement_date_taken ) add_up
    36                ,      lead(measurement_date_taken) over (partition by study_key
    37                                                          order by measurement_date_taken ) last_rec
    38                from   t
    39              )
    40         where last_rec is null
    41       )
    42  where rownum <= add_up
    43  connect by level <= add_up;
    STUDY_KEY PHASE_START_DATE    MEASUREMENT_DATE_TA STUDY_END_DATE
          1063 01-03-2009 00:00:00 02-03-2009 00:00:00 01-04-2009 00:00:00
          1063 03-03-2009 00:00:00 04-03-2009 00:00:00 01-04-2009 00:00:00
          1063 03-03-2009 00:00:00 09-03-2009 00:00:00 01-04-2009 00:00:00
          1063 03-03-2009 00:00:00 14-03-2009 00:00:00 01-04-2009 00:00:00
          1063 03-03-2009 00:00:00 19-03-2009 00:00:00 01-04-2009 00:00:00
          1063 22-03-2009 00:00:00 23-03-2009 00:00:00 01-04-2009 00:00:00
          1063 22-03-2009 00:00:00 30-03-2009 00:00:00 01-04-2009 00:00:00
          1063 22-03-2009 00:00:00 31-03-2009 00:00:00 01-04-2009 00:00:00
          1063 22-03-2009 00:00:00 01-04-2009 00:00:00 01-04-2009 00:00:00
    9 rijen zijn geselecteerd.If there's a simpler way (in SQL), I hope others will join and share their example/ideas/thoughts.
    I have a feeling that this is using more resources than needed.
    But I've got to cut the daisies first now, they interfere my 'lawn-green-ess' ;)

Maybe you are looking for

  • Please let me know if this is possibe, and how to do it.

    hi, can some one let me know how to achive the o/p mentioned below. with  target as (select 100 profile , 2 key , 'XYZ' value  from dual union all select  100,2,'ABC' from dual union all select  100,2,'CDE' from dual union all select  100,3,'300' fro

  • Error Message when launching PS CC trial

    I just downloaded and installed Photoshop CC for my windows 8 computer and every time I click on the application it comes up with a message saying there was a problem with the licensing of this program and to restart my computer. It also says that if

  • Creating user groups using SQ03.

    I am going to make a change to a already existing query 01 in the user group /SAPQUERY/AM. I am not a query expert, in fact this is the second query that I am modifing. I am reading some documentation that the first thing that I have to do is create

  • OMBuilderException detail unsupported element in SOAPFault element

    Hi, I am trying to access the Sharepoint web services using JAVA. I get this error when I try to execute a search. Sharepoint 2013 FormsBasedAuthentication .NET 4.5 SOAP 1.2 UPDATE: I tried changing the SOAP version for the Stub to 1.1  The error cha

  • Memory recommendations

    Hello I was wondering if there are any recommendations on a 64-bit JVM and usage of more than 4GB of memory? Also, are there any impacts or concerns running multiple application server JVMs in Solaris 10 containers using either Sun JVM or BEA JRockit