Data pump + inserting new values in a table

Hello Everybody!!
My question is : is it possible to insert new row into a table which is included in running DataPump process (export data) ?
Best regards
Marcin Migdal

Have a look here, never done it myself but seems kind of cool :)
http://www.pythian.com/blogs/766/oracle-data-pump-11g-little-known-new-feature

Similar Messages

  • How to insert new values in dropdown box through coding

    hi,
      I want to insert new values in dropdown box in a table.
    Please provide me the corresponding coding.i already did this code but result is empty dropdown.I mapped the context properly..
    int sklength=wdContext.nodeSkills().size();
          for(int i=0;i<sklength;i++)
        String getsub=wdContext.currentSkillsElement().getSubject();
        if(getsub.equals("50000138"))
             //IPrivateDetails1.INewskillElement el=wdContext.createNewskillElement();
             List lis=new ArrayList();
             //lis.add("Abap");
             //lis.add("Workflow");
             IPrivateDetails1.INewskillElement el=wdContext.createNewskillElement();
             el.setTskill("abap");
             lis.add(el);
              el.setTskill("workflow");
              lis.add(el);
              wdContext.nodeNewskill().bind(lis);
              //wdContext.nodeMonthsOfYear().bind(MonthsOfYear);
              wdContext.nodeNewskill().setLeadSelection(1);
        else
              wdContext.currentNewskillElement().setTskill("C++");
    waiting for a positive reply......
    with regards,
    S.Kiruthika

    kiruthika,
    Too many logical errors to explian.
    Should be:
    IPrivateDetails1.ISkillsNode nSkills = wdContext.nodeSkills();
    IPrivateDetails1.INewskillNode nNewSkill = wdContext.nodeNewskill();
    int sklength = nSkills.size();
    boolean cppAdded = false;
    for(int i=0;i<sklength;i++)
      String getsub=nSkills.getSkillsElementAt(i).getSubject();
      if(getsub.equals("50000138"))
        List lis=new ArrayList();
        IPrivateDetails1.INewskillElement el1 = nNewSkill.createNewskillElement();
        el1.setTskill("abap");
        lis.add(el1);
        IPrivateDetails1.INewskillElement el2 = nNewSkill.createNewskillElement();
        el2.setTskill("workflow");
        lis.add(el2);
        nNewSkill.bind(lis);
        nNewSkill.setLeadSelection(1);
      else if (!cppAdded)
        cppAdded = true;
        IPrivateDetails1.INewskillElement elCpp = nNewSkill.currentNewskillElement();   
        if (null ==  elCpp) {
          elCpp = nNewSkill.createNewskillElement();
          nNewskill.addElement(elCpp);
          nNewskill.setLeadSelection( nNewskill.size() - 1);
        elCpp.setTskill("C++");
    VS

  • Inserting new records into database table at runtime

    Hi all ,
    How to insert new records into database table at runtime on click update?
    Thanks.

    Hi Sasikala,
    Just for your understanding am giving a sample code snippet which you can use to read the contents of your Table UI element & save the data on to your database. Suppose you have a button up on pressing which you want to read the data from your screens table & save on to the database then you can proceed as shown below:
    1) Obtain the reference of your context node.
    2) Fetch all the data present in your table into an internal table using methods of if_wd_context_node
    3) Use your normal ABAP logic to update the database table with the data from your internal table
    In my example I have a node by name SFLIGHT_NODE and under this I have the desired attributes from SFLIGHT. Am displaying these in an editable table & the user would press up on a push button after making the necessary changes to the tables data. I would then need to obtain the tables information & save on to the database.
    data: node_sflight           type ref to if_wd_context_node,
            elem_sflight           type ref to if_wd_context_element,
            lt_elements            type WDR_CONTEXT_ELEMENT_SET,
           stru_sflight           type if_main=>element_sflight_node,
           it_flights             type if_main=>elements_sflight_node.
    "   navigate from <CONTEXT> to <SFLIGHT_NODE> via lead selection
        node_sflight_node = wd_context->get_child_node( name = 'SFLIGHT_NODE'  ).
       lt_elements = node_sflight->get_elements( ).
    "   Get all the rows from the table for saving on to the database
        loop at lt_elements into elem_sflight.
          elem_sflight->get_static_attributes( importing static_attributes = stru_sflight ).
          append stru_sflight to it_flights.
        endloop.
    " Finally save the entries on to the database
        modify ZSFLIGHT99 from table it_flights.
        if sy-subrc eq 0.
    endif.
    However a word of caution here.... SAP doesn't ever recommend directly modifying the database through an SQL query. You would preferably make use of a BAPI for the same. Try go through Thomas Jung's comments in [here|modify the data base table which is comming dynamiclly;.
    Regards,
    Uday

  • Recursive query to calculate new value in a table.

    Hello folks,
    I have following data.
    drop table transactions;
    create table transactions
    ( ac varchar2(10), rec_seq int, tr_ref int, action varchar2(100), qty int );
    select * from transactions;
    insert into transactions values ('A1', 1, null, 'BUY', 1);
    insert into transactions values ('A1', 2, null, 'BUY', 4);
    insert into transactions values ('A1', 3, 1, 'TR to A2', -2);
    insert into transactions values ('A1', 4, null, 'SELL', -1);
    insert into transactions values ('A1', 5, 2, 'TR from A2', 2);
    insert into transactions values ('A1', 6, null, 'BUY', 5);
    insert into transactions values ('A1', 3, 3, 'TR to A3', -1);
    insert into transactions values ('A2', 1, null, 'BUY', 5);
    insert into transactions values ('A2', 2, null, 'BUY', 5);
    insert into transactions values ('A2', 3, null, 'BUY', 5);
    insert into transactions values ('A2', 4, 1, 'TR from A1', 2);
    insert into transactions values ('A2', 5, null, 'SELL', 2);
    insert into transactions values ('A2', 6, null, 'BUY', 1);
    insert into transactions values ('A2', 7, null, 'BUY', 1);
    insert into transactions values ('A2', 8, 2, 'TR to A1', -2);
    insert into transactions values ('A2', 9, null, 'sell', 3);
    insert into transactions values ('A2', 10, 4, 'TR from A3', 3);
    insert into transactions values ('A3', 1, null, 'BUY', 5);
    insert into transactions values ('A3', 2, 3, 'TR from A1', 1);
    insert into transactions values ('A3', 3, null, 'SELL', 2);
    insert into transactions values ('A3', 4, 4, 'TR to A2', -3);I the transactions table that holds the activity took place in a time. Below is some description of the table.
    1. rec_seq is the unique for each row within each AC value
    2. action column holds the nature of the activity
    3. tr_ref holds to link between the transfers. That is, source and destination of the transfers can be matched using this column.
    Now I want to write a query such that It returns the whole table with value of rec_seq changed in a recursive fashion that is
    1. Compare transfer records using tr_ref.
    2. Assign the greatest rec_seq to both the records.
    3. Recalculate the rec_seq of the following records from the new value. This recalculation to happen in a recursive fashion.
    Any hint/partial or full assistance in this will immensely help.
    Thank you.
    Girish

    Hi,
    Transfers are the key events in this problem. Every time there is a transfer, the new rec_seq number has to be adjusted. The new rec_seq value will be the greater of two numbers:
    (1) the req_seq of the last transfer in this ac, plus the number of other transactions in this ac since then, and
    (2) the req_seq of the last transfer in the other ac, plus the number of other transactions in that ac since then.
    (I assume a transfer always involves two different ac's. If not, the query below can be changed.)
    One way to approach this problem is to think of a directed graph, where every node is a transfer row, and it may have up to two parents:
    (1) the previous transfer in the same ac
    (2) the previous transfer in the other ac
    The query below constructs such a graph, then finds all the paths through that graph (in the sub-query named graph). It finds the longest path to each node (weighted by the number of rows between transactions). The main query references that number, and assigns consectuive new_rec_seqs starting with it.
    WITH     got_trs  AS
         SELECT     ac, rec_seq, tr_ref, action, qTy
         ,     LAST_VALUE (tr_ref IGNORE NULLS)  OVER ( PARTITION BY  ac
                                                           ORDER BY      rec_seq
                                            ROWS BETWEEN  UNBOUNDED PRECEDING
                                             AND  1            PRECEDING
                                           )        AS prev_tr
         ,       LAST_VALUE (tr_ref IGNORE NULLS)  OVER ( PARTITION BY  ac
                                                           ORDER BY      rec_seq     DESC
                                                 )        AS next_tr
         FROM    transactions
    --     WHERE     ...     -- if you need any filtering, put it here
    ,     got_tr_cnt     AS
         SELECT     got_trs.*
         ,     COUNT (*) OVER ( PARTITION BY  ac
                                  ,            next_tr
                          )    AS tr_cnt
         FROM    got_trs
    ,     nodes     AS
         SELECT     ac
         ,     tr_ref
         ,     tr_cnt
         ,     ac          AS parent_ac
         ,     prev_tr          AS parent_tr
         FROM     got_tr_cnt
         WHERE     tr_ref     IS NOT NULL
        UNION
         SELECT     s.ac
         ,     s.tr_ref
         ,     o.tr_cnt
         ,     o.ac          AS parent_ac
         ,     o.prev_tr     AS parent_tr
         FROM     got_tr_cnt     s
         JOIN     got_tr_cnt      o  ON     s.tr_ref     = o.tr_ref
                           AND     s.ac          != o.ac
         WHERE     o.prev_tr        IS NOT NULL
    ,     graph     AS
         SELECT     tr_ref
         ,     MAX ( LENGTH ( REPLACE ( SYS_CONNECT_BY_PATH ( LPAD ('.', tr_cnt, '.')
                    )     AS start_pt
         FROM     nodes
         START WITH     parent_tr     IS NULL
         CONNECT BY     parent_tr     = PRIOR tr_ref
              AND     parent_ac     = PRIOR ac
         GROUP BY     tr_ref
    SELECT       t.ac
    ,       t.rec_seq
    ,       t.tr_ref
    ,       t.action
    ,       t.qty
    ,       NVL ( g.start_pt
               , 1
               ) + ROW_NUMBER () OVER ( PARTITION BY  ac
                                            ,          NVL ( t.tr_ref
                                                    , t.prev_tr
                                            ORDER BY          rec_seq
              - 1     AS new_rec_seq
    FROM           got_trs  t
    LEFT OUTER JOIN      graph       g  ON  g.tr_ref     = NVL ( t.tr_ref
                                                       , t.prev_tr
    ORDER BY  t.ac
    ,            t.rec_seq
    ;Output:
    AC    REC_SEQ TR_REF ACTION     QTY NEW_REC_SEQ
    A1          1        BUY          1           1
    A1          2        BUY          4           2
    A1          3      1 TR to A2    -2           4
    A1          4        SELL        -1           5
    A1          5      2 TR from A2   2           8
    A1          6        BUY          5           9
    A1          7      3 TR to A3    -1          10
    A2          1        BUY          5           1
    A2          2        BUY          5           2
    A2          3        BUY          5           3
    A2          4      1 TR from A1   2           4
    A2          5        SELL         2           5
    A2          6        BUY          1           6
    A2          7        BUY          1           7
    A2          8      2 TR to A1    -2           8
    A2          9        sell         3           9
    A2         10      4 TR from A3   3          12
    A3          1        BUY          5           1
    A3          2      3 TR from A1   1          10
    A3          3        SELL         2          11
    A3          4      4 TR to A2    -3          12I don't recommend trying to store this number in the table; it will be a nightmare trying to keep it up to date. However, if you do want to store it in the table, you can use something like the query above in a MERGE statement.
    When trying to understnad any quiery that uses sub-queries, it can be helpful to run the individual sub-queries by themselves, and study the output.

  • How to insert new record into altered table

    I am using JDBC with MySQL. I altered existing table and want to insert new record using java class. But it is not possible.How to do?

    How is it "not possible"?
    Either modify the Class for the new fields, or give the new fields default values (if applicable). If the type of an existing column has changed, then only the first option is available.
    Where's the problem?

  • Create a procedure and inovke it to insert those values in to table

    Hii
    i created a procedure with parameters modes in it.
    1 CREATE OR REPLACE PROCEDURE proc_salaris(emp_no IN emp.empno%type, sal_mon OUT emp.sal%type,hiredat_day OUT emp.hiredate%type) IS
    BEGIN
    SELECT hiredate, sal INTO hiredat_day, sal_mon from emp where empno = emp_no;
    INSERT into emp_2(empno, sal, hiredate) values(emp_no, sal_mon,hiredat_day);
    end;
    SQL> /
    Procedure created.
    now ia m trying to invoke this procedure to populate the values in to table emp_2 which as structure of emp but no values.
    declare
    sal_mon emp.sal%type;
    hiredat_day emp.hiredate%type;
    begin
    proc_sal(7844,sal_mon, hiredat_day);
    end;
    PL/SQL procedure successfully completed.
    but when i see the data in the table i see no rows selected.
    SQL> select * from emp_2;
    no rows selected.
    plz help
    thanks
    sharath

    Strange procedure but cannot reproduce what you have posted here.
    SQL> create table emp_2 as select * from emp where 1 = 2;
    Table created.
    Procedure created.
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2  sal_mon emp.sal%type;
      3  hiredat_day emp.hiredate%type;
      4  begin
      5  proc_salaris(7844,sal_mon, hiredat_day);
      6* end;
    SQL> /
    PL/SQL procedure successfully completed.
    SQL> select * from emp_2;
         EMPNO ENAME      JOB              MGR HIREDATE                   SAL       COMM     DEPTNO
          7844                                 08.09.1981 00:00:00       1500

  • Data Pump .xlsx into a SQL Server Table and the whole 32-Bit, 64-Bit discussion

    First of all...I have a headache!
    Found LOTS of Google hits when trying to data pump a .xlsx File into a SQL Server Table. And the whole discussion of the Microsoft ACE 64-Bit Driver or the Microsoft Jet 32-Bit Driver.
    Specifically receiving this error...
    An OLE DB record is available.  Source: "Microsoft Office Access Database Engine"  Hresult: 0x80004005  Description: "External table is not in the expected format.".
    Error: 0xC020801C at Data Flow Task to Load Alere Coaching Enrolled, Excel Source [56]: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.  The AcquireConnection method call to the connection manager "Excel Connection Manager"
    failed with error code 0xC0202009.
    Strangely enough, if I simply data pump ONE .xlsx File into a SQL Server Table utilizing my SSIS Package, it seems to work fine. If instead I am trying to be pro-active and allowing for multiple .xlsx Files by using a Foreach Loop Container and a variable
    @[User::FileName], it's erroring out...but not really because it is indeed storing the rows onto the SQL Server Table. I did check all my Delay
    Why does this have to be sooooooo difficult???
    Can anyone help me out here in trying to set-up a SSIS Package in a rather constrictive environment to pump a .xlsx File into a SQL Server Table? What in God's name am I doing wrong? Or is all this a misnomer? But if it's working how do I disable the error
    so that is stops erroring out?

    Hi ITBobbyP,
    According to your description, when you import data of .xlsx file to SQL Server database, you got the error message.
    The error can be caused by the following reasons:
    The excel file is locked by other processes. Please kindly resave this file and name it to other file name to see if the issue will be fixed.
    The ACE(Access Database Engine) is not up to date as Vaibhav mentioned. Please download the latest ACE and install it from the link:
    https://www.microsoft.com/en-us/download/details.aspx?id=13255.
    The version of OFFICE and server bitness is not the same. To solve the problem, please refer to the following document:
    http://hrvoje.piasevoli.com/2010/09/01/importing-data-from-64-bit-excel-in-ssis/
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu
    Wendy Fu
    TechNet Community Support

  • Server 2010 SP2 - New values in lookup table are not updated in the user client

    Hello,
    I added a value to a lookup table in the PWA.
    Most users see the new value in the field based on this lookup table.
    One user doesn't see the update for 2 weeks now. He did close and opened the application over these 2 weeks.
    Any Idea?
    Thanks,
    Barak

    Hi Barak,
    I am assuming the issue is with PWA? Has the user tried to access PWA from a different machine/browser?Other things you can try are:
    - Reset IE settings
    - CTRL+F5 (on the page)
    If it is MS Project that doesn't have the new value, try closing MS Project and re-open it
    Hope this helps
    Paul

  • Insert the values form one table to another

    Hi.,
    I am using jdev11.1.5
    I had created a reaadonly VO using the follwing querry
    select distinct fp_bu,fp_year,fp_period, decode(gdh_status,'R','Yes','No') distribution,decode (aj_status ,'N','Yes','No') Recursion,
    decode(RSUPHD_STATUS,'P','Yes','No') Supplier,decode(RCDOC_STATUS,'P','Yes','No') Customer
    from gl_dist_hd,fin_periods,appl_journals,rec_suplr_doc_hd,rec_cust_doc_hd
    where fp_bu = gdh_bu(+) and
    gdh_bu = aj_bu(+) and
    aj_bu = RSUPHD_BU(+) and
    RSUPHD_BU = RCDOC_BU(+) and
    fp_year = gdh_year(+) and
    gdh_year = aj_year(+) and
    aj_year = RSUPHD_DOC_YEAR(+) and
    RSUPHD_DOC_YEAR = RCDOC_DOC_YEAR(+) and
    fp_period = gdh_period(+) and
    gdh_period = aj_period(+) and
    aj_period = RSUPHD_DOC_PERIOD(+) and
    RSUPHD_DOC_PERIOD = RCDOC_DOC_PERIOD(+)
    ORDER BY fp_period asci had created a button [post]
    when the user clicks the button it must insert the values of table CursorC1 into GlJrnlHd
    i had tried a querry in AMImpl
            ViewObjectImpl vo = this.getGlJrnlHd1();
            Row newRow = vo.createRow();
            ViewObjectImpl c1 = this.getCursorC1_1();
            Row cr1 = c1.getCurrentRow();
               newRow.setAttribute("GjhBu", cr1.getAttribute("GrhBu"));
           newRow.setAttribute("GjhPlant", cr1.getAttribute("GrhPlant"));
          newRow.setAttribute("GjhJrnlType", cr1.getAttribute("GrvlJrnlType"));
           newRow.setAttribute("GjhJrnlNo", cr1.getAttribute("GrvlJrnlNo"));
           newRow.setAttribute("GjhJrnlSfx", cr1.getAttribute("GrhJrnlSfx"));
           newRow.setAttribute("GjhJrnlDate", "Null");
           newRow.setAttribute("GjhYear", cr1.getAttribute("GrvlYear"));
           newRow.setAttribute("GjhPeriod", cr1.getAttribute("GrvlPeriod"));
           newRow.setAttribute("GjhDesc", cr1.getAttribute("GrhDesc"));
           newRow.setAttribute("GjhAppl", "GLM");
           newRow.setAttribute("GjhReversal", "N");
           newRow.setAttribute("GjhStatus","N");
           newRow.setAttribute("GjhCreBy", "NULL");
           newRow.setAttribute("GjhCreDate", "NULL");
           newRow.setAttribute("GjhUpdBy", "NULL");
           newRow.setAttribute("GjhUpdDate", "NULL");
           this.getTransaction().commit();i am getting null pointer exception at this line
    newRow.setAttribute("GjhBu", cr1.getAttribute("GrhBu"));could anyone please help me to resolve this error

    Hi,
    give a NPE check
    ViewObjectImpl vo = this.getGlJrnlHd1();
            Row newRow = vo.createRow();
            ViewObjectImpl c1 = this.getCursorC1_1();
            Row cr1 = c1.getCurrentRow();
            if (cr1 != null){
            newRow.setAttribute("GjhBu", cr1.getAttribute("GrhBu"));
           newRow.setAttribute("GjhPlant", cr1.getAttribute("GrhPlant"));
          newRow.setAttribute("GjhJrnlType", cr1.getAttribute("GrvlJrnlType"));
           newRow.setAttribute("GjhJrnlNo", cr1.getAttribute("GrvlJrnlNo"));
           newRow.setAttribute("GjhJrnlSfx", cr1.getAttribute("GrhJrnlSfx"));
           newRow.setAttribute("GjhJrnlDate", "Null");
           newRow.setAttribute("GjhYear", cr1.getAttribute("GrvlYear"));
           newRow.setAttribute("GjhPeriod", cr1.getAttribute("GrvlPeriod"));
           newRow.setAttribute("GjhDesc", cr1.getAttribute("GrhDesc"));
           newRow.setAttribute("GjhAppl", "GLM");
           newRow.setAttribute("GjhReversal", "N");
           newRow.setAttribute("GjhStatus","N");
           newRow.setAttribute("GjhCreBy", "NULL");
           newRow.setAttribute("GjhCreDate", "NULL");
           newRow.setAttribute("GjhUpdBy", "NULL");
           newRow.setAttribute("GjhUpdDate", "NULL");
           this.getTransaction().commit();
    }

  • Unsaved new values disappear on table column sort

    Guys,
    I have an af:table.
    I display row from a view object. One of them is from calculated attribute (attr1). I show attr1 on the table.
    1. i create a new row on the table.
    2. provide value to the attr1
    3. sort the column of attr1
    4. The value which was input in step 2 disappears.
    How this can be resolved?

    non - persistent value will not retains their values, you wont save those things.
    someother way to retains the value in theri place until session kills.
    1.take groovy support for the viewobject - attribute
    2.take getter/setter method of viewobjectimpl.

  • Toplink insert new value issues

    Hi all,
    I'm working on toplink and encounter a problem.
    I have 3 tables, A(a.id), B(b.id) and relation table AB(a.id(fk),b.id(fk)),
    Now table B have one value(b1)(b1 got from sessionBean.findByid method ),
    I want to add a new value A(a1) to database, and the relation table AB(a1,b1)
    So I have the following code.
    A a = new A();
    List listAB= new ArrayList();
    AB ab = new AB();
    ab.SetB(b1);
    listAB.add(ab);
    a.setAB(ab);
    sessionBean.persisA(A)
    But the toplink persis B(b1) once again.
    So there is an error,because b1 already exists in Database.
    Anyone have solution for this problem.
    Thanks.

    The problem is in what sessionBean.persisA(a) does, and what the sessionBean.findByid does - is it just a register object? Also, you describe the A->B table relationship as a Many to Many using an AB as the relation table, but in the objects you seem to create an AB object for the relation table. Is there a reason A just isn't using a collection of Bs with a ManyToManyMapping specifying AB as the relation table? In the code description, you also state a.setAB(ab); which I assume was just a mistake and that the problem really uses a.setAB(listAB), but just to be sure, what do the ab.setB() and a.setAB() methods do, and how is the AB->A value set?
    Best Regards,
    Chris

  • How to insert new value into an array

    I have an already declared array (including the size) and want to write a method for inserting a new value. Do I have to re-declare the array to the new size? ie old size + 1, then add the new value or is there a java method for this. I can't find one.
    Thanks in advance....
    Mike

    Hi,
    there is no method for that. Look up class Vector. That class implements automatic growing of the Vector.
    Phil

  • I have to insert lookup values into parent table remaining items in chiled table can you please any one explain the logic

    CREATE OR REPLACE
    PACKAGE BODY xxcsi_ib_data_ob_ecs_pkg
      v_update_date DATE := SYSDATE;
    PROCEDURE print_log(
        i_message IN VARCHAR2)
    IS
    BEGIN
      -- dbms_output.put_line('Log '||TO_CHAR(sysdate,'DD-MON-YYYY HH24:MI:SS :')||i_message);
      fnd_file.put_line(fnd_file.LOG,'Log '||TO_CHAR(SYSDATE,'DD-MON-YYYY HH24:MI:SS :')||i_message);
    EXCEPTION
    WHEN no_data_found THEN
      NULL;
    WHEN OTHERS THEN
      NULL;
    END;
    PROCEDURE main_prc(
        o_chr_errbuff OUT VARCHAR2 ,
        o_num_retcode OUT NUMBER ,
        i_org_id IN NUMBER)
    IS
      CURSOR cur_get_parent_ib_rec(c_from DATE ,c_to DATE)
      IS
        SELECT
          /*+ index(a CSI_ITEM_INSTANCES_X3)*/
          ---CREATE MODE ITEM
          A.creation_date ,
          A.last_update_date ,
          A.last_oe_order_line_id line_id ,
          A.inventory_item_id ,
          A.instance_id ,
          A.instance_type_code ,
          msib.segment1
        FROM csi_item_instances A ,
          mtl_system_items_b msib
        WHERE 1=1
          --      AND a.instance_id = 33371916
          --AND a.instance_id in (33371920,33371921,33371922,33371923,33371924,33371925,33371926,33371927,33371928,33371929,33371930)
        AND msib.inventory_item_id=A.inventory_item_id
        AND msib.organization_id  =
          (SELECT mp.organization_id
          FROM mtl_parameters mp
          WHERE mp.organization_code = 'IMO'
        -- AND msib.organization_id = 85
        -- and msib.segment1 like '475%'
        --AND msib.segment1 like 'TREX%'
      AND EXISTS
        (SELECT 1
        FROM fnd_lookup_values
        WHERE lookup_type = 'EMR CSI OUTBOUND INTERFACE PSG'
        AND language      = 'US'
        AND lookup_code   = msib.segment1
        --and DESCRIPTION = 'Items to be Interfaced from Oracle EBS to ECS'
      AND A.last_update_date BETWEEN NVL(c_from ,to_date('07-AUG-2014 00:00:00','DD-MON-YYYY HH24:MI:SS')) AND NVL(c_to ,to_date('22-AUG-2014 00:00:00','DD-MON-YYYY HH24:MI:SS'))
      UNION
      SELECT
        /*+ index(a CSI_ITEM_INSTANCES_X3)*/
        ---CREATE MODE SEARCH
        A.creation_date ,
        A.last_update_date ,
        A.last_oe_order_line_id line_id ,
        A.inventory_item_id ,
        A.instance_id ,
        A.instance_type_code ,
        msib.segment1
      FROM csi_item_instances A ,
        mtl_system_items_b msib
      WHERE 1=1
        --AND a.instance_id = 33371916
        --AND a.instance_id in (33371920,33371921,33371922,33371923,33371924,33371925,33371926,33371927,33371928,33371929,33371930)
      AND msib.inventory_item_id=A.inventory_item_id
      AND msib.organization_id  =
        (SELECT mp.organization_id
        FROM mtl_parameters mp
        WHERE mp.organization_code = 'IMO'
        -- AND msib.organization_id = 85
        -- and msib.segment1 like '475%'
        --AND msib.segment1 like 'TREX%'
      AND EXISTS
        (SELECT 1
        FROM fnd_lookup_values
        WHERE lookup_type           = 'EMR CSI OUTBOUND INTERFACE PSG'
        AND language                = 'US'
        AND tag                     ='ALL TREX ITEMS'
        AND SUBSTR(lookup_code,1,4) = SUBSTR(msib.segment1,1,4)
        --and DESCRIPTION = 'Items to be Interfaced from Oracle EBS to ECS'
      AND A.last_update_date BETWEEN NVL(c_from ,to_date('07-AUG-2014 00:00:00','DD-MON-YYYY HH24:MI:SS')) AND NVL(c_to ,to_date('22-AUG-2014 00:00:00','DD-MON-YYYY HH24:MI:SS'))
      UNION
      SELECT
        /*+ index(a CSI_ITEM_INSTANCES_X3)*/
        ---UPDATE MODE ITEM
        A.creation_date ,
        A.last_update_date ,
        A.last_oe_order_line_id line_id ,
        A.inventory_item_id ,
        A.instance_id ,
        A.instance_type_code ,
        msib.segment1
      FROM csi_item_instances A ,
        mtl_system_items_b msib
      WHERE 1=1
        --AND a.instance_id = 33371916
        --AND a.instance_id in (33371920,33371921,33371922,33371923,33371924,33371925,33371926,33371927,33371928,33371929,33371930)
      AND msib.inventory_item_id=A.inventory_item_id
      AND msib.organization_id  =
        (SELECT mp.organization_id
        FROM mtl_parameters mp
        WHERE mp.organization_code = 'IMO'
        -- AND msib.organization_id = 85
        -- and msib.segment1 like '475%'
        --AND msib.segment1 like 'TREX%'
      AND EXISTS
        (SELECT 1
        FROM fnd_lookup_values
        WHERE lookup_type = 'EMR CSI OUTBOUND INTERFACE PSG'
        AND language      = 'US'
        AND lookup_code   = msib.segment1
        --and DESCRIPTION = 'Items to be Interfaced from Oracle EBS to ECS'
      AND A.last_update_date BETWEEN NVL(c_from ,to_date('07-AUG-2014 00:00:00','DD-MON-YYYY HH24:MI:SS')) AND NVL(c_to ,to_date('22-AUG-2014 00:00:00','DD-MON-YYYY HH24:MI:SS'))
      AND EXISTS
        (SELECT
          /*+ index(ct CSI_TRANSACTIONS_U01)*/
          1
        FROM csi_item_instances_h h ,
          csi_transactions ct
        WHERE 1                     =1
        AND ct.transaction_type_id IN (1)
        AND ct.transaction_id       = h.transaction_id
        AND ct.last_update_date BETWEEN NVL(c_from ,to_date('07-AUG-2014 00:00:00','DD-MON-YYYY HH24:MI:SS')) AND NVL(c_to ,to_date('22-AUG-2014 00:00:00','DD-MON-YYYY HH24:MI:SS'))
        AND A.instance_id =h.instance_id
      UNION
      SELECT
        /*+ index(a CSI_ITEM_INSTANCES_X3)*/
        ---UPDATE MODE SEARCH
        A.creation_date ,
        A.last_update_date ,
        A.last_oe_order_line_id line_id ,
        A.inventory_item_id ,
        A.instance_id ,
        A.instance_type_code ,
        msib.segment1
      FROM csi_item_instances A ,
        mtl_system_items_b msib
      WHERE 1=1
        --AND a.instance_id = 33371916
        --AND a.instance_id in (33371920,33371921,33371922,33371923,33371924,33371925,33371926,33371927,33371928,33371929,33371930)
      AND msib.inventory_item_id=A.inventory_item_id
      AND msib.organization_id  =
        (SELECT mp.organization_id
        FROM mtl_parameters mp
        WHERE mp.organization_code = 'IMO'
        -- AND msib.organization_id = 85
        -- and msib.segment1 like '475%'
        --AND msib.segment1 like 'TREX%'
      AND EXISTS
        (SELECT 1
        FROM fnd_lookup_values
        WHERE lookup_type           = 'EMR CSI OUTBOUND INTERFACE PSG'
        AND language                = 'US'
        AND tag                     ='ALL TREX ITEMS'
        AND SUBSTR(lookup_code,1,4) = SUBSTR(msib.segment1,1,4)
        --and DESCRIPTION = 'Items to be Interfaced from Oracle EBS to ECS'
      AND A.last_update_date BETWEEN NVL(c_from ,to_date('07-AUG-2014 00:00:00','DD-MON-YYYY HH24:MI:SS')) AND NVL(c_to ,to_date('22-AUG-2014 00:00:00','DD-MON-YYYY HH24:MI:SS'))
      AND EXISTS
        (SELECT
          /*+ index(ct CSI_TRANSACTIONS_U01)*/
          1
        FROM csi_item_instances_h h ,
          csi_transactions ct
        WHERE 1                     =1
        AND ct.transaction_type_id IN (1)
        AND ct.transaction_id       = h.transaction_id
        AND ct.last_update_date BETWEEN NVL(c_from ,to_date('07-AUG-2014 00:00:00','DD-MON-YYYY HH24:MI:SS')) AND NVL(c_to ,to_date('22-AUG-2014 00:00:00','DD-MON-YYYY HH24:MI:SS'))
        AND A.instance_id =h.instance_id
      ORDER BY 1 DESC,
        2 ;
      CURSOR cur_get_child_ib_rec(c_instance_id NUMBER)
      IS
        SELECT cir.subject_id
        FROM csi.csi_ii_relationships cir
        WHERE cir.object_id = c_instance_id;
      CURSOR cur_get_outbound_data(c_instance_id NUMBER)
      IS
        SELECT cii.instance_id instance_id,
          cii.instance_number instance_number,
          cii.inventory_item_id inventory_item_id,
          msi.segment1 segment1,       --CONCATENATED_SEGMENTS,
          msi.description description, --DESCRIPTION,
          cii.inv_master_organization_id master_organization_id,
          cii.serial_number serial_number,
          cii.system_id system_id,
          cst.NAME system_name,
          cii.quantity quantity,
          cii.unit_of_measure uom,
          cii.active_start_date active_start_date,
          cii.active_end_date active_end_date,
          cii.install_date install_date,
          cii.object_version_number object_version_number,
          cii.last_vld_organization_id,
          hou.NAME pre_registration_location,
          looh.header_id last_header_id,
          looh.order_number emerson_order_number,
          cii.last_oe_order_line_id order_line_id,
          NVL(lool.actual_shipment_date, lool.fulfillment_date) actual_shipment_date,
          (SELECT DISTINCT pap.email_address
          FROM fnd_user fu ,
            per_all_people_f pap
          WHERE fu.employee_id = pap.person_id
          and sysdate between pap.effective_start_date and nvl(pap.effective_end_date, sysdate)
          AND fu.user_id       = NVL(wdd.created_by,lool.created_by)
          ) email_address,
        (SELECT DISTINCT hp.party_name
        FROM hz_parties hp,
          hz_party_sites hps ,
          hz_party_site_uses hpsu ,
          hz_locations hl
        WHERE hp.party_id     = hps.party_id
        AND hps.location_id   = hl.location_id
        AND hps.party_site_id = hpsu.party_site_id(+)
        AND hps.party_site_id =
          (SELECT hcasa.party_site_id
          FROM apps.hz_cust_acct_sites hcasa
          WHERE hcasa.cust_acct_site_id =
            (SELECT hcsua.cust_acct_site_id
            FROM apps.hz_cust_site_uses hcsua
            WHERE cia.bill_to_address = hcsua.site_use_id
        ) AS "Bill_To_company_name",--------------------------CH-ID-1.1 STARTS-----------
        (SELECT DISTINCT hps.party_site_id
        FROM hz_parties hp,
          hz_party_sites hps ,
          hz_party_site_uses hpsu ,
          hz_locations hl
        WHERE hp.party_id     = hps.party_id
        AND hps.location_id   = hl.location_id
        AND hps.party_site_id = hpsu.party_site_id(+)
        AND hps.party_site_id =
          (SELECT hcasa.party_site_id
          FROM apps.hz_cust_acct_sites hcasa
          WHERE hcasa.cust_acct_site_id =
            (SELECT hcsua.cust_acct_site_id
            FROM apps.hz_cust_site_uses hcsua
            WHERE cia.bill_to_address = hcsua.site_use_id
        ) AS "BILL_TO_party_SITE_ID",
        (SELECT DISTINCT hl.state
        FROM hz_parties hp,
          hz_party_sites hps ,
          hz_party_site_uses hpsu ,
          hz_locations hl
        WHERE hp.party_id     = hps.party_id
        AND hps.location_id   = hl.location_id
        AND hps.party_site_id = hpsu.party_site_id(+)
        AND hps.party_site_id =
          (SELECT hcasa.party_site_id
          FROM apps.hz_cust_acct_sites hcasa
          WHERE hcasa.cust_acct_site_id =
            (SELECT hcsua.cust_acct_site_id
            FROM apps.hz_cust_site_uses hcsua
            WHERE cia.bill_to_address = hcsua.site_use_id
        ) AS "BILL_TO_STATE",
        (SELECT DISTINCT hl.country
        FROM hz_parties hp,
          hz_party_sites hps ,
          hz_party_site_uses hpsu ,
          hz_locations hl
        WHERE hp.party_id     = hps.party_id
        AND hps.location_id   = hl.location_id
        AND hps.party_site_id = hpsu.party_site_id(+)
        AND hps.party_site_id =
          (SELECT hcasa.party_site_id
          FROM apps.hz_cust_acct_sites hcasa
          WHERE hcasa.cust_acct_site_id =
            (SELECT hcsua.cust_acct_site_id
            FROM apps.hz_cust_site_uses hcsua
            WHERE cia.bill_to_address = hcsua.site_use_id
        ) AS "BILL_TO_COUNTRY",
        (SELECT DISTINCT hl.city
        FROM hz_parties hp,
          hz_party_sites hps ,
          hz_party_site_uses hpsu ,
          hz_locations hl
        WHERE hp.party_id     = hps.party_id
        AND hps.location_id   = hl.location_id
        AND hps.party_site_id = hpsu.party_site_id(+)
        AND hps.party_site_id =
          (SELECT hcasa.party_site_id
          FROM apps.hz_cust_acct_sites hcasa
          WHERE hcasa.cust_acct_site_id =
            (SELECT hcsua.cust_acct_site_id
            FROM apps.hz_cust_site_uses hcsua
            WHERE cia.bill_to_address = hcsua.site_use_id
        ) AS "BILL_TO_CITY",
        (SELECT DISTINCT hl.address1
        FROM hz_parties hp,
          hz_party_sites hps ,
          hz_party_site_uses hpsu ,
          hz_locations hl
        WHERE hp.party_id     = hps.party_id
        AND hps.location_id   = hl.location_id
        AND hps.party_site_id = hpsu.party_site_id(+)
        AND hps.party_site_id =
          (SELECT hcasa.party_site_id
          FROM apps.hz_cust_acct_sites hcasa
          WHERE hcasa.cust_acct_site_id =
            (SELECT hcsua.cust_acct_site_id
            FROM apps.hz_cust_site_uses hcsua
            WHERE cia.bill_to_address = hcsua.site_use_id
        ) AS "BILL_TO_LOCATION",
        (SELECT DISTINCT hp.party_name
        FROM hz_parties hp,
          hz_party_sites hps,
          hz_party_site_uses hpsu,
          hz_locations hl
        WHERE hp.party_id     = hps.party_id
        AND hps.location_id   = hl.location_id
        AND hps.party_site_id = hpsu.party_site_id(+)
        AND hps.party_site_id =
          (SELECT hcasa.party_site_id
          FROM apps.hz_cust_acct_sites hcasa
          WHERE hcasa.cust_acct_site_id =
            (SELECT hcsua.cust_acct_site_id
            FROM apps.hz_cust_site_uses hcsua
            WHERE cia.ship_to_address = hcsua.site_use_id
        ) AS "Ship_to_company_name",
        (SELECT DISTINCT hps.party_site_id
        FROM hz_parties hp,
          hz_party_sites hps ,
          hz_party_site_uses hpsu ,
          hz_locations hl
        WHERE hp.party_id     = hps.party_id
        AND hps.location_id   = hl.location_id
        AND hps.party_site_id = hpsu.party_site_id(+)
        AND hps.party_site_id =
          (SELECT hcasa.party_site_id
          FROM apps.hz_cust_acct_sites hcasa
          WHERE hcasa.cust_acct_site_id =
            (SELECT hcsua.cust_acct_site_id
            FROM apps.hz_cust_site_uses hcsua
            WHERE cia.bill_to_address = hcsua.site_use_id
        ) AS "SHIP_TO_party_SITE_ID",
        (SELECT DISTINCT hl.state
        FROM hz_parties hp,
          hz_party_sites hps ,
          hz_party_site_uses hpsu ,
          hz_locations hl
        WHERE hp.party_id     = hps.party_id
        AND hps.location_id   = hl.location_id
        AND hps.party_site_id = hpsu.party_site_id(+)
        AND hps.party_site_id =
          (SELECT hcasa.party_site_id
          FROM apps.hz_cust_acct_sites hcasa
          WHERE hcasa.cust_acct_site_id =
            (SELECT hcsua.cust_acct_site_id
            FROM apps.hz_cust_site_uses hcsua
            WHERE cia.bill_to_address = hcsua.site_use_id
        ) AS "SHIP_TO_STATE",
        (SELECT DISTINCT hl.country
        FROM hz_parties hp,
          hz_party_sites hps ,
          hz_party_site_uses hpsu ,
          hz_locations hl
        WHERE hp.party_id     = hps.party_id
        AND hps.location_id   = hl.location_id
        AND hps.party_site_id = hpsu.party_site_id(+)
        AND hps.party_site_id =
          (SELECT hcasa.party_site_id
          FROM apps.hz_cust_acct_sites hcasa
          WHERE hcasa.cust_acct_site_id =
            (SELECT hcsua.cust_acct_site_id
            FROM apps.hz_cust_site_uses hcsua
            WHERE cia.bill_to_address = hcsua.site_use_id
        ) AS "SHIP_TO_COUNTRY",
        (SELECT DISTINCT hl.city
        FROM hz_parties hp,
          hz_party_sites hps ,
          hz_party_site_uses hpsu ,
          hz_locations hl
        WHERE hp.party_id     = hps.party_id
        AND hps.location_id   = hl.location_id
        AND hps.party_site_id = hpsu.party_site_id(+)
        AND hps.party_site_id =
          (SELECT hcasa.party_site_id
          FROM apps.hz_cust_acct_sites hcasa
          WHERE hcasa.cust_acct_site_id =
            (SELECT hcsua.cust_acct_site_id
            FROM apps.hz_cust_site_uses hcsua
            WHERE cia.bill_to_address = hcsua.site_use_id
        ) AS "SHIP_TO_CITY",
        (SELECT DISTINCT hl.address1
        FROM hz_parties hp,
          hz_party_sites hps ,
          hz_party_site_uses hpsu ,
          hz_locations hl
        WHERE hp.party_id     = hps.party_id
        AND hps.location_id   = hl.location_id
        AND hps.party_site_id = hpsu.party_site_id(+)
        AND hps.party_site_id =
          (SELECT hcasa.party_site_id
          FROM apps.hz_cust_acct_sites hcasa
          WHERE hcasa.cust_acct_site_id =
            (SELECT hcsua.cust_acct_site_id
            FROM apps.hz_cust_site_uses hcsua
            WHERE cia.bill_to_address = hcsua.site_use_id
        ) AS "SHIP_TO_LOCATION",
        (SELECT DISTINCT hl.postal_code
        FROM hz_parties hp,
          hz_party_sites hps ,
          hz_party_site_uses hpsu ,
          hz_locations hl
        WHERE hp.party_id     = hps.party_id
        AND hps.location_id   = hl.location_id
        AND hps.party_site_id = hpsu.party_site_id(+)
        AND hps.party_site_id =
          (SELECT hcasa.party_site_id
          FROM apps.hz_cust_acct_sites hcasa
          WHERE hcasa.cust_acct_site_id =
            (SELECT hcsua.cust_acct_site_id
            FROM apps.hz_cust_site_uses hcsua
            WHERE cia.bill_to_address = hcsua.site_use_id
        ) AS "SHIP_TO_PIN_CODE",
        (SELECT DISTINCT hl.postal_code
        FROM hz_parties hp,
          hz_party_sites hps ,
          hz_party_site_uses hpsu ,
          hz_locations hl
        WHERE hp.party_id     = hps.party_id
        AND hps.location_id   = hl.location_id
        AND hps.party_site_id = hpsu.party_site_id(+)
        AND hps.party_site_id =
          (SELECT hcasa.party_site_id
          FROM apps.hz_cust_acct_sites hcasa
          WHERE hcasa.cust_acct_site_id =
            (SELECT hcsua.cust_acct_site_id
            FROM apps.hz_cust_site_uses hcsua
            WHERE cia.bill_to_address = hcsua.site_use_id
        ) AS "BILL_TO_PIN_CODE",
        (SELECT hcsua.LOCATION
        FROM apps.hz_cust_site_uses_all hcsua
        WHERE cia.ship_to_address = hcsua.site_use_id
        ) "SHIP_TO_NUMBER",
        (SELECT hcsua.LOCATION
        FROM apps.hz_cust_site_uses_all hcsua
        WHERE cia.bill_to_address = hcsua.site_use_id
        ) "BILL_TO_NUMBER",
        (SELECT DISTINCT hca.account_number
        FROM hz_cust_accounts hca
        WHERE hca.cust_account_id =
          (SELECT hcasa.cust_account_id
          FROM apps.hz_cust_acct_sites hcasa
          WHERE hcasa.cust_acct_site_id =
            (SELECT hcsua.cust_acct_site_id
            FROM apps.hz_cust_site_uses hcsua
            WHERE cia.bill_to_address = hcsua.site_use_id
        )AS "CUSTOMER_NUMBER", --------------------------CH-ID-1.1 ENDS -----------
        (SELECT civ.attribute_value
        FROM csi_iea_values civ,
          csi_i_extended_attribs ciea
        WHERE civ.attribute_id  = ciea.attribute_id
        AND ciea.attribute_code = '011 LICENSE NUMBER'
        AND civ.instance_id     = cii.instance_id
        ) AS "EA_LICENSE_NUMBER",
        (SELECT civ.attribute_value
        FROM csi_iea_values civ,
          csi_i_extended_attribs ciea
        WHERE civ.attribute_id  = ciea.attribute_id
        AND ciea.attribute_code = 'VA_SALES_ORDER_NUMBER'
        AND civ.instance_id     = cii.instance_id
        ) AS "EA_VA_SALES_ORDER_NUM",
        (SELECT NAME
        FROM hr_all_organization_units
        WHERE organization_id = cii.inv_master_organization_id
        ) master_organization_name
      FROM csi_item_instances cii,
        csi_systems_tl cst,
        --    MTL_SYSTEM_ITEMS_VL MSIKFV,
        --    MTL_SYSTEM_ITEMS MSI,
        mtl_system_items_b msi,
        hr_all_organization_units hou,
        oe_order_lines lool,
        oe_order_headers looh,
        wsh_delivery_details wdd,
        csi_i_parties cip,
        csi_ip_accounts cia
      WHERE cii.last_vld_organization_id = msi.organization_id
      AND cii.inventory_item_id          = msi.inventory_item_id
        --  AND CII.LAST_VLD_ORGANIZATION_ID   = MSIKFV.ORGANIZATION_ID
        --  AND CII.INVENTORY_ITEM_ID          = MSIKFV.INVENTORY_ITEM_ID
      AND hou.organization_id(+)    = cii.last_vld_organization_id
      AND cii.last_oe_order_line_id = lool.line_id
      AND lool.header_id            = looh.header_id
      AND cii.last_oe_order_line_id = wdd.source_line_id
        --      AND WDD.SOURCE_LINE_ID             = LOOL.LINE_ID
        --      AND WDD.SOURCE_HEADER_ID           = LOOH.HEADER_ID
      AND cii.instance_id               = cip.instance_id
      AND cii.system_id                 = cst.system_id(+)
      AND cip.party_source_table        = 'HZ_PARTIES'
      AND cip.relationship_type_code    = 'OWNER'
      AND cip.instance_party_id         = cia.instance_party_id
      AND cia.relationship_type_code(+) = 'OWNER'
      AND cii.instance_status_id        = 1052
      AND cst.language(+)               = 'US'
      AND cii.instance_id               = c_instance_id;
      CURSOR cur_get_ib_warranty (c_instance_id NUMBER)
      IS
        SELECT kh.contract_number,
          kh.scs_code,
          kh.start_date,
          kh.end_date,
          (kh.end_date-kh.start_date) duration,
          clet.NAME coverage_name,
          clet.item_description coverage_desc,
          b.segment1 service_name,
          t.description service_desc
        FROM okc_k_headers_b kh,
          okc_k_lines_b kl,
          okc_k_items ki,
          csi_item_instances c,
          mtl_system_items_b i,
          okc_k_lines_b cleb,
          okc_k_lines_tl clet,
          okc_k_items ki1,
          mtl_system_items_b_kfv b,
          mtl_system_items_tl t
        WHERE kh.contract_number_modifier IS NULL
        AND kh.ID                          = kl.dnz_chr_id
        AND kh.ID                          = ki.dnz_chr_id
        AND kl.ID                          = ki.cle_id
        AND ki.jtot_object1_code          IN ('OKX_CUSTPROD')
        AND c.last_vld_organization_id     = i.organization_id
        AND ki.object1_id1                 = TO_CHAR(c.instance_id)
        AND c.inventory_item_id            = i.inventory_item_id
        AND kl.cle_id                      = cleb.cle_id
        AND cleb.ID                        = clet.ID
        AND clet.language               = userenv('LANG')
        AND cleb.lse_id                   IN (2,15,20)
        AND cleb.cle_id                    = ki1.cle_id
        AND b.inventory_item_id            = t.inventory_item_id
        AND b.organization_id              = t.organization_id
        AND t.language                     = userenv('LANG')
        AND to_number(ki1.object1_id1)     = b.inventory_item_id
        AND to_number(ki1.object1_id2)     = b.organization_id
        AND c.instance_id                  = c_instance_id;
      --v1.2 comment ends
      CURSOR cur_get_to_date( c_req_id NUMBER,c_conc_prog_id NUMBER)
      IS
        SELECT requested_start_date
        FROM fnd_concurrent_requests
        WHERE request_id          = c_req_id
        AND concurrent_program_id = c_conc_prog_id;
      /*Record Type Declaration*/
    TYPE ib_ecs_dat_record
    IS
      record
        instance_id csi_item_instances.instance_id%TYPE,
        instance_number csi_item_instances.instance_number%TYPE,
        inventory_item_id csi_item_instances.inventory_item_id%TYPE,
        segment1 mtl_system_items_b.segment1%TYPE,
        description mtl_system_items_b.description%TYPE,
        master_organization_id csi_item_instances.inv_master_organization_id%TYPE,
        serial_number csi_item_instances.serial_number%TYPE,
        system_id csi_item_instances.system_id%TYPE,
        system_name csi_systems_tl.NAME%TYPE,
        quantity csi_item_instances.quantity%TYPE,
        uom csi_item_instances.unit_of_measure%TYPE,
        active_start_date csi_item_instances.active_start_date%TYPE,
        active_end_date csi_item_instances.active_end_date%TYPE,
        install_date csi_item_instances.install_date%TYPE,
        obj_version_num csi_item_instances.object_version_number%TYPE,
        last_vld_organization_id csi_item_instances.last_vld_organization_id%TYPE,
        pre_registration_location VARCHAR2(500),
        order_header_id oe_order_headers_all.header_id%TYPE,
        order_number oe_order_headers_all.order_number%TYPE,
        order_line_id csi_item_instances.last_oe_order_line_id%TYPE,
        actual_shipment_date oe_order_lines_all.actual_shipment_date%TYPE,
        email_address per_all_people_f.email_address%TYPE,
        bill_to_company_name hz_parties.party_name%TYPE,
        bill_to_site_id hz_party_sites.party_site_id%TYPE,
        bill_to_state hz_locations.state%TYPE,
        bill_to_country hz_locations.country%TYPE,
        bill_to_city hz_locations.city%TYPE,
        bill_to_location hz_locations.address1%TYPE,
        ship_to_company_name hz_parties.party_name%TYPE,
        ship_to_site_id hz_party_sites.party_site_id%TYPE,
        ship_to_state hz_locations.state%TYPE,
        ship_to_country hz_locations.country%TYPE,
        ship_to_city hz_locations.city%TYPE,
        ship_to_location hz_locations.address1%TYPE,
        ship_to_pin_code hz_locations.postal_code%TYPE,
        bill_to_pin_code hz_locations.postal_code%TYPE,
        ship_to_number hz_cust_site_uses_all.LOCATION%TYPE,
        bill_to_number hz_cust_site_uses_all.LOCATION%TYPE,
        customer_number hz_cust_accounts.account_number%TYPE,
        ea_license_number csi_iea_values.attribute_value%TYPE,
        ea_va_sales_order_num csi_iea_values.attribute_value%TYPE,
        master_organization_name hr_all_organization_units.NAME%TYPE );
    TYPE tab_typ_ib_ecs_dat
    IS
      TABLE OF ib_ecs_dat_record INDEX BY binary_integer;
    TYPE ib_parent_dat_record
    IS
      record
        creation_date DATE,
        last_update_date DATE,
        order_line_id csi_item_instances.last_oe_order_line_id%TYPE,
        inventory_item_id csi_item_instances.inventory_item_id%TYPE,
        instance_id csi_item_instances.instance_id%TYPE,
        instance_type_code csi_item_instances.instance_type_code%TYPE,
        segment1 mtl_system_items_b.segment1%TYPE );
    TYPE tab_typ_ib_parent_dat
    IS
      TABLE OF ib_parent_dat_record INDEX BY binary_integer;
      --/*Record Type Declaration*/
      --      TYPE parent_ib_record IS RECORD (
      --         creation_date           csi_item_instances.creation_date%TYPE,
      --         last_update_date        csi_item_instances.last_update_date%TYPE,
      --         inventory_item_id       csi_item_instances.inventory_item_id%TYPE,
      --         instance_id             csi_item_instances.instance_id%TYPE,
      --         instance_type_code      csi_item_instances.instance_type_code%TYPE,
      --         segment1                mtl_system_items_b.segment1%type
      --      TYPE tab_typ_par_ib_collection IS TABLE OF parent_ib_record
      --         INDEX BY BINARY_INTEGER;
      --      tab_par_ib_rec                   tab_typ_par_ib_collection;
      v_segment1 mtl_system_items_b.segment1%TYPE;
      v_request_id        NUMBER := fnd_global.conc_request_id;
      v_conc_prog_id      NUMBER := fnd_global.conc_program_id;
      v_created_by        NUMBER := fnd_profile.VALUE('USER_ID');
      v_last_update_login NUMBER := fnd_global.login_id;
      v_to DATE                  := SYSDATE;
      v_from DATE                := SYSDATE-100;
      v_count NUMBER             := NULL;
      --       v_header_id                        NUMBER := NULL;
      --       v_line_id                          NUMBER := NULL;
      --       v_org_id                           NUMBER := NULL;
      --       v_ship_from_org_id                 NUMBER := NULL;
      --v1.2 begin
      --       v_master_org_id                    NUMBER := NULL;
      --       v_item_type                        VARCHAR2(100) := null;
      --       v_top_model_line_id                NUMBER := NULL;
      --       v_serial_tag_number                VARCHAR2(100) := null;
    TYPE tbl_req_start_date_type
    IS
      TABLE OF DATE INDEX BY pls_integer;
      tbl_req_start_date tbl_req_start_date_type;
      --v1.2 ends
      --v1.3 starts
      --      v_flow_status_code                  VARCHAR2(100) := null;
      --      v_line_number                       NUMBER        := NULL;
      --      v_shipment_number                   NUMBER        := NULL;
      --      v_option_number                     NUMBER        := NULL;
      --      v_component_number                  NUMBER        := NULL;
      --      v_service_number                    NUMBER       := NULL;
      --v1.3 ends
      --      v_model_string                      VARCHAR2(100) := NULL;
      --      v_end_cust                          NUMBER := NULL;
      --      v_end_cust_site_id                  NUMBER := NULL;
      --      v_location_type_code                VARCHAR2(100) := null;
      --      v_location_id                       NUMBER := NULL;
      --      v_tag                               VARCHAR2(100) := NULL;
      --      v_inventory_item_status             VARCHAR2(100) := NULL;
      --      v_serial_number                     VARCHAR2(100) := NULL;
      --      v_serial_return                     VARCHAR2(200) := NULL;
      --rec_ext_attr      Rec_Ext_Attr_type ;
      v_ret_error_message VARCHAR2(2000):= NULL;
      v_ret_error_flag    VARCHAR2(1)   := NULL;
      v_error_message     VARCHAR2(2000):= NULL;
      v_error_flag        VARCHAR2(1)   := NULL;
      v_error_at          VARCHAR2(100) := NULL;
      --        v_to1                               DATE   := sysdate;
      --        v_from1                             DATE   := sysdate-45;
      tab_ib_parent_dat tab_typ_ib_parent_dat;
      tab_ib_ecs_dat tab_typ_ib_ecs_dat;
      tab_ib_ecs_dat_c tab_typ_ib_ecs_dat;
    BEGIN
      print_log('*********************************************************************');
      print_log('print log message 01');
      print_log('Process Starts... : '||to_date(SYSDATE,'DD-MON-YYYY HH24:MI:SS'));
      v_error_at := 'Start of the process';
      fnd_client_info.set_org_context(i_org_id);
      --  v1.2 begins, to get from date ----==----
      BEGIN
        print_log('print log message 02');
        --OPEN  get_from_date( v_request_id,v_conc_prog_id);
        --FETCH get_from_date INTO   v_from;
        --CLOSE get_from_date;
        v_error_at := 'main Process/ before from ';
        --        v_from := Sysdate-15;
        v_from := SYSDATE-45;
        --Added v1.4 ,AND    ARGUMENT1 = i_org_id
        SELECT
          /*+ index(a FND_CONCURRENT_REQUESTS_N6) index(a FND_CONCURRENT_REQUESTS_N7)*/
          requested_start_date BULK COLLECT
        INTO tbl_req_start_date
        FROM fnd_concurrent_requests
        WHERE request_id            < v_request_id
        AND concurrent_program_id   = v_conc_prog_id
        AND argument1               = i_org_id
        AND status_code             ='C'
        AND phase_code              ='C';
        v_error_at                 := 'main Process/ after from selection ';
        IF tbl_req_start_date.count >0 THEN
          FOR i                    IN tbl_req_start_date.FIRST .. tbl_req_start_date.LAST
          LOOP
            IF v_from < tbl_req_start_date(i) THEN
              v_from := tbl_req_start_date(i);
              print_log( 'Tabel Req StartDate : '||tbl_req_start_date(i));
              print_log( 'In the Loop VFrom : '||v_from);
            END IF;
          END LOOP;
        END IF;
        v_error_at := 'main Process/ after from Loop ';
        print_log( 'Out the loop v_from is : '||v_from);
      EXCEPTION
      WHEN no_data_found THEN
        print_log('Error in  from_date process exception : '||sqlerrm);
        print_log('Error at : '||v_error_at);
        v_from := NULL;
      WHEN OTHERS THEN
        print_log('Error in  from_date process exception : '||sqlerrm);
        print_log('Error at : '||v_error_at);
        v_from := NULL;
      END;
      -- v1.2 ends---==----
      print_log('print log message 03');
      BEGIN
        OPEN cur_get_to_date ( v_request_id,v_conc_prog_id);
        FETCH cur_get_to_date INTO v_to;
        CLOSE cur_get_to_date;
        --v1.3 starts
        v_update_date := v_to -(1/86400);
        --v1.3 ends
        v_error_at := 'main Process/ after from and to date';
        print_log('v_from1... : '||TO_CHAR(v_from,'DD-MON-YYYY HH24:MI:SS'));
        print_log('v_to1  ... : '||TO_CHAR(v_to ,'DD-MON-YYYY HH24:MI:SS'));
        --v1.3 starts
        print_log('Updated v_to  ... : '||TO_CHAR(v_update_date ,'DD-MON-YYYY HH24:MI:SS'));
        --v1.3 ends
      EXCEPTION
      WHEN no_data_found THEN
        print_log('Error in  main process1 : '||sqlerrm);
        print_log('Error at : '||v_error_at);
      WHEN OTHERS THEN
        print_log('Error in  main process1 : '||sqlerrm);
        print_log('Error at : '||v_error_at);
      END;
      BEGIN
        print_log('print log message 04');
        OPEN cur_get_parent_ib_rec(v_from ,v_to);
        LOOP
          print_log('After Loop Get Records v_from... : '||TO_CHAR(v_from,'DD-MON-YYYY HH24:MI:SS'));
          print_log('After Loop Get Records v_to  ... : '||TO_CHAR(v_to ,'DD-MON-YYYY HH24:MI:SS'));
          FETCH cur_get_parent_ib_rec BULK COLLECT INTO tab_ib_parent_dat;
          print_log('Parent Instance first : ');
          --  FOR i IN 1 .. tab_ib_parent_dat.COUNT
          print_log('print log message 05');
          FOR i IN tab_ib_parent_dat.FIRST .. tab_ib_parent_dat.LAST
          LOOP
            BEGIN
              print_log('Parent Instance : '||tab_ib_parent_dat(i).instance_id);
              print_log('====================================================================');
              v_error_at       := 'main Process/ start of the loop';
              v_ret_error_flag := NULL;
              v_segment1       := NULL;
            EXCEPTION
            WHEN no_data_found THEN
              print_log('Error in  main process exception1 : '||sqlerrm);
              print_log('Error at : '||v_error_at);
            WHEN OTHERS THEN
              print_log('Error in  main process exception1 : '||sqlerrm);
              print_log('Error at : '||v_error_at);
            END;
            OPEN cur_get_outbound_data(tab_ib_parent_dat(i).instance_id);
            LOOP
              FETCH cur_get_outbound_data BULK COLLECT INTO tab_ib_ecs_dat;
              --FOR j IN 1 .. tab_ib_ecs_dat.COUNT
              FOR j IN tab_ib_ecs_dat.FIRST .. tab_ib_ecs_dat.LAST
              LOOP
                BEGIN
                BEGIN
                     SELECT COUNT(1)
                      INTO v_count
                      FROM apps.xxcsi_trex_ob_ecs_mhm
                      WHERE instance_id  = NVL(tab_ib_ecs_dat_c(j).instance_id,'');
                    EXCEPTION
                    WHEN OTHERS THEN
                      v_count := 0;
                    END;
                    print_log('v_count : '||v_count);
                    IF v_count = 0 THEN
                  --        print_log('PARENT_DAT: '||NVL(tab_ib_ecs_dat(j).instance_id);
            print_log('print log message 06');
                  INSERT
                  INTO xxcsi_trex_ob_ecs_mhm
                      instance_id,
                      instance_number,
                      inventory_item_id,
                      unit,
                      unit_name,
                      master_organization_id,
                      serial_number,
                      quantity,
                      uom,
                      active_start_date,
                      active_end_date,
                      install_date,
                      object_version_number,
                      last_vld_organization_id,
                      pre_registration_location,
                      order_header_id,
                      order_number,
                      order_line_id,
                      pre_registration_date,
                      pre_registration_operator,
                      bill_to_customer_name,
                      bill_to_site_id ,
                      bill_to_state ,
                      bill_to_country ,
                      bill_to_city ,
                      bill_to_location ,
                      ship_to_customer_name,
                      ship_to_site_id ,
                      ship_to_state ,
                      ship_to_country ,
                      ship_to_city ,
                      ship_to_location,
                      ship_to_pin_code,
                      bill_to_pin_code,
                      ship_to_number,
                      bill_to_number,
                      customer_number,
                      ea_license_number,
                      ea_va_sales_order_number,
                      parent_instance_id,
                      parent_y_n,
                      process_flag,
                      error_code,
                      error_details,
                      request_id,
                      created_by,
                      creation_date,
                      last_updated_by,
                      last_update_date,
                      last_update_login,
                      eai_process_flag,
                      master_organization_name,
                      system_id,
                      system_name
                    VALUES
                      NVL(tab_ib_ecs_dat(j).instance_id,''),
                      NVL(tab_ib_ecs_dat(j).instance_number,''),
                      NVL(tab_ib_ecs_dat(j).inventory_item_id,''),
                      NVL(tab_ib_ecs_dat(j).segment1,''),
                      NVL(tab_ib_ecs_dat(j).description,''),
                      NVL(tab_ib_ecs_dat(j).master_organization_id,''),
                      NVL(tab_ib_ecs_dat(j).serial_number,''),
                      NVL(tab_ib_ecs_dat(j).quantity,''),
                      NVL(tab_ib_ecs_dat(j).uom,''),
                      NVL(tab_ib_ecs_dat(j).active_start_date,''),
                      NVL(tab_ib_ecs_dat(j).active_end_date,''),
                      NVL(tab_ib_ecs_dat(j).install_date,''),
                      NVL(tab_ib_ecs_dat(j).obj_version_num,''),
                      NVL(tab_ib_ecs_dat(j).last_vld_organization_id,''),
                      NVL(tab_ib_ecs_dat(j).pre_registration_location,''),
                      NVL(tab_ib_ecs_dat(j).order_header_id,''),
                      NVL(tab_ib_ecs_dat(j).order_number,''),
                      NVL(tab_ib_ecs_dat(j).order_line_id,''),
                      NVL(tab_ib_ecs_dat(j).actual_shipment_date,''),
                      NVL(tab_ib_ecs_dat(j).email_address,''),
                      NVL(tab_ib_ecs_dat(j).bill_to_company_name,''),
                      NVL(tab_ib_ecs_dat(j).bill_to_site_id,''),
                      NVL(tab_ib_ecs_dat(j).bill_to_state,''),
                      NVL(tab_ib_ecs_dat(j).bill_to_country,''),
                      NVL(tab_ib_ecs_dat(j).bill_to_city,''),
                      NVL(tab_ib_ecs_dat(j).bill_to_location,''),
                      NVL(tab_ib_ecs_dat(j).ship_to_company_name,''),
                      NVL(tab_ib_ecs_dat(j).ship_to_site_id,''),
                      NVL(tab_ib_ecs_dat(j).ship_to_state,''),
                      NVL(tab_ib_ecs_dat(j).ship_to_country,''),
                      NVL(tab_ib_ecs_dat(j).ship_to_city,''),
                      NVL(tab_ib_ecs_dat(j).ship_to_location,''),
                      NVL(tab_ib_ecs_dat(j).ship_to_pin_code,''),
                      NVL(tab_ib_ecs_dat(j).bill_to_pin_code,''),
                      NVL(tab_ib_ecs_dat(j).ship_to_number,''),
                      NVL(tab_ib_ecs_dat(j).bill_to_number,''),
                      NVL(tab_ib_ecs_dat(j).customer_number,''),
                      NVL(tab_ib_ecs_dat(j).ea_license_number,''),
                      NVL(tab_ib_ecs_dat(j).ea_va_sales_order_num,''),
                      NULL,
                      'P',
                      'N',
                      NULL,
                      NULL,
                      v_request_id,
                      v_created_by,
                      SYSDATE,
                      v_created_by,
                      SYSDATE,
                      v_last_update_login,
                      'N',
                      NVL(tab_ib_ecs_dat(j).master_organization_name,''),
                      NVL(tab_ib_ecs_dat(j).system_id,''),
                      NVL(tab_ib_ecs_dat(j).system_name,'')
    ELSE
    Update apps.xxcsi_trex_ob_ecs_mhm set 
                    instance_id=NVL(tab_ib_ecs_dat_c(j).instance_id,''),
      instance_number= NVL(tab_ib_ecs_dat_c(j).instance_number,''),
                    inventory_item_id= NVL(tab_ib_ecs_dat_c(j).inventory_item_id,''),
                    unit      = NVL(tab_ib_ecs_dat_c(j).segment1,''),
                    unit_name =  NVL(tab_ib_ecs_dat_c(j).description,''),
                    master_organization_id=NVL(tab_ib_ecs_dat_c(j).master_organization_id,''),
                    --serial_number=NVL(tab_ib_ecs_dat_c(j).serial_number,''),
                    quantity= NVL(tab_ib_ecs_dat_c(j).quantity,''),
                    uom=NVL(tab_ib_ecs_dat_c(j).uom,''),
                    active_start_date= NVL(tab_ib_ecs_dat_c(j).active_start_date,''),
                    active_end_date= NVL(tab_ib_ecs_dat_c(j).active_end_date,''),
                    install_date= NVL(tab_ib_ecs_dat_c(j).install_date,''),
                    object_version_number=NVL(tab_ib_ecs_dat_c(j).obj_version_num,''),
                    last_vld_organization_id= NVL(tab_ib_ecs_dat_c(j).last_vld_organization_id,''),
                    pre_registration_location=NVL(tab_ib_ecs_dat_c(j).pre_registration_location,''),
                    order_header_id=NVL(tab_ib_ecs_dat_c(j).order_header_id,''),
                    order_number= NVL(tab_ib_ecs_dat_c(j).order_number,''),
                    order_line_id=NVL(tab_ib_ecs_dat_c(j).order_line_id,''),
                    pre_registration_date= NVL(tab_ib_ecs_dat_c(j).actual_shipment_date,''),
                    pre_registration_operator= NVL(tab_ib_ecs_dat_c(j).email_address,''),
                    bill_to_customer_name=NVL(tab_ib_ecs_dat_c(j).bill_to_company_name,''),
                    bill_to_site_id = NVL(tab_ib_ecs_dat_c(j).bill_to_site_id,''),
                    bill_to_state = NVL(tab_ib_ecs_dat_c(j).bill_to_state,''),
                    bill_to_country =NVL(tab_ib_ecs_dat_c(j).bill_to_country,''),
                    bill_to_city = NVL(tab_ib_ecs_dat_c(j).bill_to_city,''),
                    bill_to_location =  NVL(tab_ib_ecs_dat_c(j).bill_to_location,''),
                    ship_to_customer_name=NVL(tab_ib_ecs_dat_c(j).ship_to_company_name,''),
                    ship_to_site_id = NVL(tab_ib_ecs_dat_c(j).ship_to_site_id,''),
                    ship_to_state =NVL(tab_ib_ecs_dat_c(j).ship_to_state,''),
                    ship_to_country=NVL(tab_ib_ecs_dat_c(j).ship_to_country,''),
                    ship_to_city =NVL(tab_ib_ecs_dat_c(j).ship_to_city,''),
                    ship_to_location= NVL(tab_ib_ecs_dat_c(j).ship_to_location,''),
      ship_to_pin_code= NVL(tab_ib_ecs_dat_c(j).ship_to_pin_code,''),
      bill_to_pin_code=NVL(tab_ib_ecs_dat_c(j).bill_to_pin_code,''),
      ship_to_number=NVL(tab_ib_ecs_dat_c(j).ship_to_number,''),
      bill_to_number= NVL(tab_ib_ecs_dat_c(j).bill_to_number,''),
      customer_number= NVL(tab_ib_ecs_dat_c(j).customer_number,''),
      ea_license_number= NVL(tab_ib_ecs_dat_c(j).ea_license_number,''),
      ea_va_sales_order_number= NVL(tab_ib_ecs_dat_c(j).ea_va_sales_order_num,''),
      parent_instance_id=NVL(tab_ib_parent_dat(i).instance_id,''),
      parent_y_n='C',
      process_flag='N',
      error_code= NULL,
      error_details= NULL,
      request_id=v_request_id,
      created_by=v_created_by,
      creation_date= SYSDATE,
      last_updated_by=v_created_by,
      last_update_date=SYSDATE,
      last_update_login= v_last_update_login,
      eai_process_flag='Y',
      master_organization_name=NVL(tab_ib_ecs_dat_c(j).master_organization_name,''),
      system_id= NVL(tab_ib_ecs_dat_c(j).system_id,''),
      system_name= NVL(tab_ib_ecs_dat_c(j).system_name,'')
      WHERE instance_id  = NVL(tab_ib_ecs_dat_c(j).instance_id,'');
      END IF; --V_COUNT
                EXCEPTION
                WHEN no_data_found THEN
                  print_log('Error in inserting Parent Instance : '||tab_ib_ecs_dat(j).instance_id||': '||sqlerrm);
                WHEN OTHERS THEN
                  print_log('Error in inserting Parent Instance : '||tab_ib_ecs_dat(j).instance_id||': '||sqlerrm);
                END;
                --      END LOOP;
              END LOOP;
              EXIT
            WHEN cur_get_outbound_data%notfound;
            END LOOP;
            CLOSE cur_get_outbound_data;
            print_log('print log message 07');
            BEGIN
              FOR rec_get_child_ib_rec IN cur_get_child_ib_rec
                tab_ib_parent_dat(i).instance_id
              LOOP
                print_log
                  'cur_get_child_ib_rec : '||tab_ib_parent_dat(i).instance_id
                OPEN cur_get_outbound_data(rec_get_child_ib_rec.subject_id);
                LOOP
                  FETCH cur_get_outbound_data BULK COLLECT INTO tab_ib_ecs_dat_c;
                  --            tab_ib_ecs_dat_c1 := tab_ib_ecs_dat_c;
                  --            FOR k IN 1 .. tab_ib_ecs_dat_c.COUNT
                  FOR k IN tab_ib_ecs_dat_c.FIRST .. tab_ib_ecs_dat_c.LAST
                  LOOP
                    print_log('Child Instance : '||tab_ib_ecs_dat_c(k).instance_id);
                    --        BEGIN
                    BEGIN
                      SELECT COUNT(1)
                      INTO v_count
                      FROM apps.xxcsi_trex_ob_ecs_mhm
                      WHERE instance_id  = NVL(tab_ib_ecs_dat_c(k).instance_id,'');
                    EXCEPTION
                    WHEN OTHERS THEN
                      v_count := 0;
                    END;
                    print_log('v_count : '||v_count);
                    IF v_count = 0 THEN
                      BEGIN
                        INSERT
                        INTO xxcsi_trex_ob_ecs_mhm
                            instance_id,
                            instance_number,
                            inventory_item_id,
                            unit,
                            unit_name,
                            master_organization_id,
                            serial_number,
                            quantity,
                            uom,
                            active_start_date,
                            active_end_date,
                            install_date,
                            object_version_number,
                            last_vld_organization_id,
                            pre_registration_location,
                            order_header_id,
                            order_number,
                            order_line_id,
                            pre_registration_date,
                            pre_registration_operator,
                            bill_to_customer_name,
                            bill_to_site_id ,
                            bill_to_state ,
                            bill_to_country ,
                            bill_to_city ,
                            bill_to_location ,
                            ship_to_customer_name,
                            ship_to_site_id ,
                            ship_to_state ,
                            ship_to_country ,
                            ship_to_city ,
                            ship_to_location ,
                            ship_to_pin_code,
                            bill_to_pin_code,
                            ship_to_number,
                            bill_to_number,
                            customer_number,
                            ea_license_number,
                            ea_va_sales_order_number,
                            parent_instance_id,
                            parent_y_n,
                            process_flag,
                            error_code,
                            error_details,
                            request_id,
                            created_by,
                            creation_date,
                            last_updated_by,
                            last_update_date,
                            last_update_login,
                            eai_process_flag,
                            master_organization_name,
                            system_id,
                            system_name
                          VALUES
                            NVL(tab_ib_ecs_dat_c(k).instance_id,''),
                            NVL(tab_ib_ecs_dat_c(k).instance_number,''),
                            NVL(tab_ib_ecs_dat_c(k).inventory_item_id,''),
                            NVL(tab_ib_ecs_dat_c(k).segment1,''),
                            NVL(tab_ib_ecs_dat_c(k).description,''),
                            NVL(tab_ib_ecs_dat_c(k).master_organization_id,''),
                            NVL(tab_ib_ecs_dat_c(k).serial_number,''),
                            NVL(tab_ib_ecs_dat_c(k).quantity,''),
                            NVL(tab_ib_ecs_dat_c(k).uom,''),
                            NVL(tab_ib_ecs_dat_c(k).active_start_date,''),
                            NVL(tab_ib_ecs_dat_c(k).active_end_date,''),
                            NVL(tab_ib_ecs_dat_c(k).install_date,''),
                            NVL(tab_ib_ecs_dat_c(k).obj_version_num,''),
                            NVL(tab_ib_ecs_dat_c(k).last_vld_organization_id,''),
                            NVL(tab_ib_ecs_dat_c(k).pre_registration_location,''),
                            NVL(tab_ib_ecs_dat_c(k).order_header_id,''),
                            NVL(tab_ib_ecs_dat_c(k).order_number,''),
                            NVL(tab_ib_ecs_dat_c(k).order_line_id,''),
                            NVL(tab_ib_ecs_dat_c(k).actual_shipment_date,''),
                            NVL(tab_ib_ecs_dat_c(k).email_address,''),
                            NVL(tab_ib_ecs_dat_c(k).bill_to_company_name,''),
                            NVL(tab_ib_ecs_dat_c(k).bill_to_site_id,''),
                            NVL(tab_ib_ecs_dat_c(k).bill_to_state,''),
                            NVL(tab_ib_ecs_dat_c(k).bill_to_coun

    The logic is:
    1. Create any new lookup table rows that may be needed
    2. Create new data rows that reference the lookup table
    All you did was post a buch of code. You didn't post ANYTHING that shows how you executed that code or what the result was.
    You need to SHOW US (not tell us):
    1. WHAT you do
    2. HOW you do it
    3. WHAT results you get
    4. WHAT results you expected to get
    The code you posted has some SERIOUS ISSUES. Here are just three of them
    1. You are using BULK COLLECT without a LIMIT clause
    2. You are using unnecessary IF . . .COUNT statements to test collections for values. The FOR clause will simply NOT execute if the collection is empty so the IF statements add unnecessary clutter.
    3. The first loop iterates a collection but sets a single SCALAR value - making that loop totally USELESS
    LOOP
            IF v_from < tbl_req_start_date(i) THEN
              v_from := tbl_req_start_date(i);
              print_log( 'Tabel Req StartDate : '||tbl_req_start_date(i));
              print_log( 'In the Loop VFrom : '||v_from);
            END IF;
          END LOOP;
    That checks EVERY row in the collection and appears to save the MAX value of 'tbl_req_state_date' into the 'v_from' variable.
    What is the point of that?

  • Trigger is not updateing the :new value in the table

    Hi,
    I've greated a row trigger that will trigger on insert statements.
    The last thing the trigger will do is to update the :NEW.role_id value in the inserted row, see the trigger bellow.
    The trigger was mutation so I had to add the 'PRAGMA AUTONOMOUS_TRANSACTION;' to avoid the mutation error.
    When performing test with controlled insert statements the trigger is working without problems, but when I my J2EE application is inserting rows to the table the role_id value is nog updated, see the trigger below and the :NEW.role_id := nRole_id; part. The role_id for the new row is empty. What can be the problem?
    CREATE OR REPLACE TRIGGER MSP_36.M2_USER_ALERT_INSERT_TRG_SCA
    BEFORE INSERT
    ON MSP_36.M2_USER_ALERT
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    ex_not_valid_role_name EXCEPTION;
    /* Variables */
    nAlertTypeId M2_USER_ALERT.alert_type%TYPE;
    isLogical      boolean;
    validRole     boolean;
    nRole_id      M2_ROLE.role_id%TYPE;
    PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
         BEGIN
              SELECT distinct at.alert_type INTO nAlertTypeId
              FROM M2_USER_ALERT ua, M2_ALERT_TYPE at,M2_ALERT_TYPE_PROPERTIES atp
              WHERE ua.alert_type = at.alert_type
              AND at.alert_type = atp.ALERT_TYPE_ID
              AND ua.alert_type = :NEW.alert_type
              AND upper(atp.property_name) = 'LOGICAL'
              AND upper(atp.property_value) = 'TRUE';
              isLogical := true;
         EXCEPTION
                   WHEN no_data_found THEN
                   isLogical := false;
                   NULL;     
         END;     
    IF (isLogical = true) THEN
    BEGIN
              SELECT distinct ro.role_id INTO nRole_id
              FROM M2_ROLE ro, M2_USER_ALERT
              WHERE ro.name = :NEW.name;
         EXCEPTION
                   WHEN no_data_found THEN
                        validRole :=false;
                        RAISE_APPLICATION_ERROR(-20001,'LOGICAL UserAlert: Role with id'|| nRole_id || ' does not exist.');     
                        NULL;
         END;
         validRole := true;
         IF (isLogical = true AND validRole = true AND :NEW.status = 1) THEN
         INSERT INTO M2_USER_ROLE (user_id,role_id)
         VALUES (:NEW.user_id,nRole_id);
         :NEW.role_id := nRole_id;
    END IF;
    END IF;
    commit;
    END;
    Many thanks,
    Michael

    I only get a empty column that include now data. The first insert is working correct so I know that the role_id is valid and working. Can there be problem with commit or my AUTONOMOUS_TRANSACTION running this from JDBC ?
    EXAMPLE data from
    M2_USER_ROLE
    ===================
    USER_ID = ROLE_ID =
    ===================
    20 = 10040 =
    1259756 = 10040 =
    ===================
    Example partly data from
    M2_USER_ALERT
    =========================================================
    USERALERT_ID = USER_ID = ALERT_TYPE = NAME = ROLE_ID =
    =========================================================
    3725 = 1259756 = 10288 = MG_Test = =
    =========================================================
    When inserted from the application the role_id is empty and I've taken the same SQL from the library cache and run it with same BIND variables and then it's working.
    Michael

  • How do you insert new records into multiple tables using the same unique primary key?

    I’ve created a PHP site and MySQL server using a free app called XAMPP.  I have successfully created a form in Dreamweaver that will write data to a (name) table in the SQL database.  Here’s my question: How do you write to two (or more) tables in the same database and pass the same primary key to both tables?  In the SQL database, I defined the first field as ID and set it as the primary key with auto update.  So, when you insert a new record, it creates a unique primary key for that record.  In my form, I’m capturing info that needs to be stored to two tables at the same time; a Name table and Address table. Since the Name and Address tables use the ID field as the primary key, I believe I will need to pass the ID value from the Name table to the insert of the Address table to insure they both have the same primary key, right?

    No. You probably need the primary key from one table to be a foreign key in the other tables. In any case, I believe you can use two methods to obtain the auto generated key. First with SQL:
    http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html
    And the other using a PHP function:
    http://us3.php.net/mysql_insert_id

Maybe you are looking for