Override INSERT operation with subquery

Hi, OTN.
I have a form to update/insert a table.
While INSERT one of the fields' value should be obtained by a subquery.
SQL operation should look like this:
INSERT INTO table1 (attribA, attribB, attribC)
VALUES (valueA, valueB, ( SELECT max(valueC) + 1
FROM table1
WHERE table1.attribA = valueA
It is necessary to complete insert in a single operation. Not possible to obtain a value with one query and insert it with another. Triggers also shouldn't be used.
So i need to use a subquery. My JDev is 11.1.1.1.0.
How is it done?
Thanks

I have problem with detailstamp not working on 11g.
Let us consider : Item , SubItem relationship.
Component : Item VO , SubItemVO , Item can have many subitem.
1.Created ItemVO
2.Create SubItemVO
3.Create View Link based on ItemVo-ItemId that is FK in SubItem table.
4.Created JSF page and Dragged ItemVO from Datacontrol to JSF Pagen as ADF ReadOnly Table.
5.Expanded Item table structure in Structure window and open the detailstamp.
6.Dragged SubItemVO in detailstamp as ADF ReadOnly table.
Expected Result :
1. ItemVO First Row
1.SubItems belonging to ITEMVO First Row
2.SubItems belonging to ITEMVO First Row
2.ItemVO Second Row.
1.SubItems belonging to ITEMVO Second Row
Current Result :
1. ItemVO First Row
1.SubItems belonging to ITEMVO First Row
2.SubItems belonging to ITEMVO First Row
2.ItemVO Second Row.
1.SubItems belonging to ITEMVO First Row
2.SubItems belonging to ITEMVO First Row
Description: Second ItemVO when expanded shows first ItemVO SUBITEMS.
Thanks,

Similar Messages

  • Database Adapter insert operation with return value

    Hi All,
    I have a table with auto generate parimary key in DB2 database. I need to have an insert operation ont this table which should return current value of primary key after insert.
    For this , I have created an insert operation in DB Adapter. But this insert operation in oneway operation.
    Is there any way I can create an Insert operation in DB2 adapter which returns the primary key value?
    Thanks
    --Sree                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi Sree,
    With insert operation it is not possible. You may use stored procedure/function to perform insert and return the required value, and call this SP/function using DB Adapter.
    Regards,
    Anuj

  • Insert statement with subquery to insert multiple rows

    Hi frnds,
    Kindly find the below mentioned query and error. Also suggest me to go ahead.
    SQL>  INSERT INTO FM_TRAN_DOC_NO (TDOC_COMP_CODE,
      2                               TDOC_TRAN_CODE,
      3                               TDOC_ACNT_YEAR,
      4                               TDOC_CUR_NO,
      5                               TDOC_MAX_NO,
      6                               TDOC_CAL_YEAR,
      7                               TDOC_PERIOD,
      8                               TDOC_DIVN_CODE,
      9                               TDOC_DEPT_CODE,
    10                               TDOC_CR_UID,
    11                               TDOC_CR_DT,
    12                               TDOC_UPD_UID,
    13                               TDOC_UPD_DT)
    14     SELECT    '001',
    15               (SELECT DISTINCT TDOC_TRAN_CODE FROM FM_TRAN_DOC_NO
    16               '6',
    17               '0',
    18               '9999',
    19               NULL,
    20               NULL,
    21               NULL,
    22               NULL,
    23               'AGT',
    24               TO_DATE (SYSDATE),
    25               NULL,
    26               TO_DATE (SYSDATE) FROM DUAL;
                 (SELECT DISTINCT TDOC_TRAN_CODE FROM FM_TRAN_DOC_NO ),
    ERROR at line 15:
    ORA-01427: single-row subquery returns more than one row

    This "SELECT DISTINCT TDOC_TRAN_CODE FROM FM_TRAN_DOC_NO" query returns multiple rows. So what is your requirement?
    Try the below insert if you want to select from tale FM_TRAN_DOC_NO
    INSERT INTO FM_TRAN_DOC_NO (TDOC_TRAN_CODE,
                                TDOC_COMP_CODE,
                                 TDOC_ACNT_YEAR,
                                 TDOC_CUR_NO,
                                 TDOC_MAX_NO,
                                 TDOC_CAL_YEAR,
                                 TDOC_PERIOD,
                                 TDOC_DIVN_CODE,
                                 TDOC_DEPT_CODE,
                                TDOC_CR_UID,
                                TDOC_CR_DT,
                                TDOC_UPD_UID,
                                TDOC_UPD_DT)
      SELECT    DISTINCT
                TDOC_TRAN_CODE
                '001',
                '6',
                '0',
                '9999',
                NULL,
                NULL,
                NULL,
                NULL,
                'AGT',
                TO_DATE (SYSDATE),
                NULL,
                TO_DATE (SYSDATE) FROM TDOC_TRAN_CODE;
    Message was edited by: 000000

  • Insert / update with subquery

    Hi,
    i have to insert (if records don't exist) or update (if records already exist) records from table S into table D. S and D have the same structure.
    Table S
    ID NUMBER, Primary Key,
    DESC1 VARCHAR
    DESC2 VARCHAR
    Table D
    ID NUMBER, Primary Key,
    DESC1 VARCHAR
    DESC2 VARCHAR
    Are this statements OK?
    INSERT INTO D
    ( SELECT * FROM S T1 WHERE NOT EXISTS
    ( SELECT '1' FROM D T2 WHERE T2.ID = T1.ID));
    UPDATE D T1
    SET (DESC1, DESC2) =
    (SELECT DESC1, DECS2
    FROM S T2 WHERE T1.ID = T2.ID ) WHERE EXIST
    ( SELECT '1' FROM S T3 WHERE T1.ID = T3.ID );
    Thanks a lot

    Depends on exist or not the data in
    the destination where id doesn't exists in the source.
    SQL> select * from updatable_tab;
    ID DESC1 DESC2
    1 0 0
    1 0 0
    1 0 0
    1 0 0
    2 f f
    2 f f
    2 f f
    2 f f
    2 f f
    9 rows selected.
    SQL> update updatable_tab dst set (desc1, desc2) =
    2 (select desc1, desc2 from s where s.id = dst.id)
    3 /
    9 rows updated.
    SQL> select * from updatable_tab;
    ID DESC1 DESC2
    1 A A
    1 A A
    1 A A
    1 A A
    2 B B
    2 B B
    2 B B
    2 B B
    2 B B
    9 rows selected.
    But if you have the row in the destination table
    wich does not exists in the source table, it will
    nullify your dest1 and dest2.
    In this case you should of course:
    SQL> select * from updatable_tab;
    ID DESC1 DESC2
    1 0 0
    1 0 0
    1 0 0
    1 0 0
    2 f f
    2 f f
    2 f f
    2 f f
    2 f f
    3 m m
    10 rows selected.
    SQL> select * from s;
    ID DESC1 DESC2
    1 A A
    2 B B
    SQL> update updatable_tab dst set (desc1, desc2) =
    2 (select desc1, desc2 from s where s.id = dst.id)
    3 where exists (select null from s where s.id = dst.id)
    4 /
    9 rows updated.
    SQL> select * from updatable_tab;
    ID DESC1 DESC2
    1 A A
    1 A A
    1 A A
    1 A A
    2 B B
    2 B B
    2 B B
    2 B B
    2 B B
    3 m m
    Rgds.

  • DIServer insert operations for sales orders with error

    DIServer insert operations for sales orders with
    That even though the insert is inserted DocDueDate DocDueDate it says error.
    Subtracting the value of the format 'yyyy-mm-dd', 'yyyy/mm/dd', 'mm-dd-yyyy', 'mm/dd/yyyy' put all reporting
    When the input is entered DocDueDate ShipDate also put together ... but I get an error.
    The error message 'env: Receiver-10Enter due date [ORDR.DocDueDate] 171AddObject2EEE7D98-AB71-464A-93AB-933F0AD3D4DC'
    Purchase order entered into the normal value because the xml is missing or wrong with you.
    Please answer all the possibilities that can be resolved
    This Xml used.
    "<BOM>" +
    "<BO>" +
    "<AdmInfo>" +
    "<Object>oOrders</Object>" +
    "</AdmInfo>" +
    "<QueryParams>" +
    "<DocEntry />" +
    "</QueryParams>" +
    "<Documents>" +
            "<row>" +
            "<DocType>I</DocType>" +
            "<DocDate>2012-01-11</DocDate>" +
            "<DocDueDate>2012-01-11</DocDueDate>" +
            "<CardCode>CD00001</CardCode>" +
            "<Address>Anymode</Address>" +
            "<DocCurrency>KRW</DocCurrency>" +
            "<Comments>[sales orders] LGU TEST</Comments>" +
            "<TaxDate>2012-01-11</TaxDate>" +
            "<JournalMemo>JournalMemo</JournalMemo>" +
            "<Address2>Addr</Address2>" +
            "<BPL_IDAssignedToInvoice>1</BPL_IDAssignedToInvoice>" +
            "</row>" +
    "</Documents>" +
    "<Document_Lines>" +
            "<row>" +
            "<ItemCode>ACDT0100ET</ItemCode>" +
            "<Quantity>1</Quantity>" +
            "<Price>5000</Price>" +
            "<DiscountPercent>10</DiscountPercent>" +
            "<WarehouseCode>A100</WarehouseCode>" +
            "<VatGroup>A2</VatGroup>" +
            "</row>" +
    "</Document_Lines>" +
    "</BO>" +
    "</BOM>";

    I had the same error change the Date to the format yyyymmdd, and problem solved.

  • How to create stored procedure for insert update and delete operations with input output paramters?

    I  have the follwing table is called master table contain the follwing fields,
    So here i need to create  three Stored procedures 
    1.Insert operations(1 o/p paramter,and  14 input paramters)              - uspInsert
    2.Update operations(1 o/p paramter,and  14 input paramters)          - uspUpdate
    3.Delete Operations(1 o/p paramter,and  14 input paramters)          
     - uspdelte
    The following is the table ,so using this to make the three sp's ,Here we will use Exception machanism also.
    Location 
    Client Name
    Owner 
    ConfigItemID
    ConfigItemName
    DeploymentID
    IncidentID
    Package Name
    Scope 
    Stage
    Type 
    Start Date
    End Date
    Accountable 
    Comments
    So can u pls help me out for this ,bcz i knew to stored procedure's creation.

    I  have the follwing table is called master table contain the follwing fields,
    So here i need to create  three Stored procedures 
    1.Insert operations(1 o/p paramter,and  14 input paramters)              - uspInsert
    2.Update operations(1 o/p paramter,and  14 input paramters)          - uspUpdate
    3.Delete Operations(1 o/p paramter,and  14 input paramters)            - uspdelte
    The following is the table ,so using this to make the three sp's ,Here we will use Exception machanism also.
    Location 
    Client Name
    Owner 
    ConfigItemID
    ConfigItemName
    DeploymentID
    IncidentID
    Package Name
    Scope 
    Stage
    Type 
    Start Date
    End Date
    Accountable 
    Comments
    So can u pls help me out for this ,bcz i knew to stored procedure's creation.
    Why you have to pass 14 parameters for DELETE and UPDATE? Do you have any Primary Key?  If you do NOT have primary key in your table then in case you have duplicate information, SQL will update both or delete them together. You need to provide DDL of
    you table. What are the data types of fields?
    Best Wishes, Arbi; Please vote if you find this posting was helpful or Mark it as answered.

  • What causes BUFFER GETS and PHYSICAL READS in INSERT operation to be high?

    Hi All,
    Am performing a huge number of INSERTs to a newly installed Oracle XE 10.2.0.1.0 on Windows. There is no SELECT statement running, but just INSERTs one after the other of 550,000 in count. When I monitor the SESSION I/O from Home > Administration > Database Monitor > Sessions, I see the following stats:
    BUFFER GETS = 1,550,560
    CONSISTENT GETS = 512,036
    PHYSICAL READS = 3,834
    BLOCK CHANGES = 1,034,232
    The presence of 2 stats confuses. Though the operation is just INSERT in database for this session, why should there be BUFFER GETS of this magnitude and why should there by PHYSICAL READS. Aren't these parameters for read operations? The BLOCK CHANGES value is clear as there are huge writes and the writes change these many blocks. Can any kind soul explain me what causes there parameters to show high value?
    The total columns in the display table are as follows (from the link mentioned above)
    1. Status
    2. SID
    3. Database Users
    4. Command
    5. Time
    6. Block Gets
    7. Consistent Gets
    8. Physical Reads
    9. Block Changes
    10. Consistent Changes
    What does CONSISTENT GETS and CONSISTENT CHANGES mean in a typical INSERT operation? And does someone know which all tables are involved in getting these values?
    Thank,
    ...

    Flake wrote:
    Hans, gracias.
    The table just have 2 columns, both of which are varchar2 (500). No constraints, no indexes, neither foreign key references are in place. The total size of RAM in system is 1GB, and yes, there are other GUI's going on like Firefox browser, notepad and command terminals.
    But, what does these other applications have to do with Oracle BUFFER GETS, PHYSICAL READS etc.? Awaiting your reply.Total RAM is 1GB. If you let XE decide how much RAM is to be allocated to buffers, on startup that needs to be shared with any/all other applications. Let's say that leaves us with, say 400M for the SGA + PGA.
    PGA is used for internal stuff, such as sorting, which is also used in determing the layout of secondary facets such as indexes and uniqueness. Total PGA usage varies in size based on the number of connections and required operations.
    And then there's the SGA. That needs to cover the space requirement for the data dictionary, any/all stored procedures and SQL statements being run, user security and so on. As well as the buffer blocks which represent the tablespace of the database. Since it is rare that the entire tablespace will fit into memory, stuff needs to be swapped in and out.
    So - put too much space pressure on the poor operating system before starting the database, and the SGA may be squeezed. Put that space pressure on the system and you may enbd up with swapping or paging.
    This is one of the reasons Oracle professionals will argue for dedicated machines to handle Oracle software.

  • Error in multiple operation with change document object for custom table

    hi all,
    I have developed a change document object for a custom table ZTEST and developed a report program for insertion, updation & deletion..everything works fine if I do only once ie. if I created only 1 entries. If I created 2 new entries , I am getting an Error "DUPREC:POS&Z3RL_TAB&Z3RL_TAB" and EXIT the transaction.
    why I am getting this error??? is it not possible to do multiple operation with the change document???
    kindly help.
    Edited by: JaiKarthik on Apr 7, 2010 6:20 AM

       LOOP AT ts_mod INTO wa_mod.
                READ TABLE <i_itab> INTO <wa_tab> INDEX wa_mod-row.
    * Select the existing entries in table Z3RL for change history
                    SELECT SINGLE * FROM z3rl
                           INTO wa_z3rl
                           WHERE vkorg   = <wa_tab>+3(4)
                           AND   zzkunnr = <wa_tab>+7(10).
    * Move the old entries
                    IF sy-subrc = 0.
                      CLEAR ls_z3rl.
                      ls_z3rl = wa_z3rl.
                    ENDIF.
    * Update the table
                 MODIFY (viewname) FROM <wa_tab>.
                   CLEAR wa_z3rl.
                    wa_z3rl-mandt      = <wa_tab>+0(3).
                    wa_z3rl-vkorg      = <wa_tab>+3(4).
                    wa_z3rl-zzkunnr    = <wa_tab>+7(10).
    * Populate change tables
                    CLEAR wa_change.
                    wa_change-teilobjid = 'Z3RL'.
                    wa_change-textart = 'TEST_2'.
                    wa_change-textspr = 'EN'.
                    wa_change-updkz = 'U'.
                    APPEND wa_change TO ts_change.
    *call the fM to log the values in CDHDR table.
                    CALL FUNCTION 'Z3RL_WRITE_DOCUMENT'
                      EXPORTING
                        objectid                 = 'Z3RL'
                        tcode                    = sy-tcode
                        utime                    = sy-uzeit
                        udate                    = sy-datum
                        username                 = sy-uname
                        planned_change_number    = ' '
                        object_change_indicator  = 'U'
                        planned_or_real_changes  = 'U'
                        no_change_pointers       = 'U'
                        upd_icdtxt_z3rl= 'U'
                        n_z3rl= wa_z3rl
                        o_z3rl        = ls_z3rl
                        upd_z3rl= 'U'
                        lv_opt                   = ' '
                      TABLES
                        icdtxt_z3rl= ts_change.
                CLEAR : wa_mod, <wa_tab>.
              ENDLOOP.
    Edited by: JaiKarthik on Apr 7, 2010 6:49 AM

  • Query in Insert statement with JDBC Rx adapter

    Hi,
    This is a FILE to JDBC scenario.
    My target datatype is like this with sample payload values
    statement_s
    statement_s
       action='INSERT"
      access
        A=1234
        B=1002
    key
       A=1234
       B ="10%"
         compareOperation= LIKE
    A(1..1) is primary key in DB and B(0..1) colunm is an optional one.
    I want to know if such kind of Insert query with(LIKE operator) is possible.
    Please reply me ASAP.
    Edited by: ram pranav on Feb 18, 2009 10:28 PM

    Hi Ram,
    IN case of "UPDATE_INSERT", you can use the KEY tag in your structure. Also you can provide LIKE as an attribute to the KEY element as follows :
    <key1>
         <col4 compareOperation=u201DLIKEu201D>val%</col4>
    </key1>
    But when you are trying to insert the data_, the <key> tags will be ignored and only <access> will be considered._
    action=UPDATE_INSERT
    The statement has the same format as for the UPDATE action. Initially, the same action is executed as for UPDATE. If no update to the database table can be made for this action (the condition does not apply to any table entry), values of the table described in the <access> element are inserted in accordance with the description of the action INSERT. <key> elements are ignored in this case.
    The response document has the following format; one of the two values is always 0 because either an UPDATE or an INSERT action is always executed:
    Go through the link I have provided earlier.
    Thanks,
    Pooja Pandey

  • Oracle 8i array DML operations with LOB objects

    Hi all,
    I have a question about Oracle 8i array DML operations with LOB objects, both CLOB and BLOB. With the following statement in mind:
    INSERT INTO TABLEX (COL1, COL2) VALUES (:1, :2)
    where COL1 is a NUMBER and COL2 is a BLOB, I want to use OCIs array DML functionality to insert multiple records with a single statement execution. I have allocated an array of LOB locators, initialized them with OCIDescriptorAlloc(), and bound them to COL2 where mode is set to OCI_DATA_AT_EXEC and dty (IN) is set to SQLT_BLOB. It is after this where I am getting confused.
    To send the LOB data, I have tried using the user-defined callback method, registering the callback function via OCIBindDynamic(). I initialize icbfps arguments as I would if I were dealing with RAW/LONG RAW data. When execution passes from the callback function, I encounter a memory exception within an Oracle dll. Where dvoid **indpp equals 0 and the object is of type RAW/LONG RAW, the function works fine. Is this not a valid methodology for CLOB/BLOB objects?
    Next, I tried performing piecewise INSERTs using OCIStmtGetPieceInfo() and OCIStmtSetPieceInfo(). When using this method, I use OCILobWrite() along with a user-defined callback designed for LOBs to send LOB data to the database. Here everything works fine until I exit the user-defined LOB write callback function where an OCI_INVALID_HANDLE error is encountered. I understand that both OCILobWrite() and OCIStmtExecute() return OCI_NEED_DATA. And it does seem to me that the two statements work separately rather than in conjunction with each other. So I rather doubt this is the proper methodology.
    As you can see, the correct method has evaded me. I have looked through the OCI LOB samples, but have not found any code that helps answer my question. Oracles OCI documentation has not been of much help either. So if anyone could offer some insight I would greatly appreciate it.
    Chris Simms
    [email protected]
    null

    Before 9i, you will have to first insert empty locators using EMPTY_CLOB() inlined in the SQL and using RETURNING clause to return the locator. Then use OCILobWrite to write to the locators in a streamed fashion.
    From 9i, you can actually bind a long buffer to each lob position without first inserting an empty locator, retrieving it and then writing to it.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by CSimms:
    Hi all,
    I have a question about Oracle 8i array DML operations with LOB objects, both CLOB and BLOB. With the following statement in mind:
    INSERT INTO TABLEX (COL1, COL2) VALUES (:1, :2)
    where COL1 is a NUMBER and COL2 is a BLOB, I want to use OCIs array DML functionality to insert multiple records with a single statement execution. I have allocated an array of LOB locators, initialized them with OCIDescriptorAlloc(), and bound them to COL2 where mode is set to OCI_DATA_AT_EXEC and dty (IN) is set to SQLT_BLOB. It is after this where I am getting confused.
    To send the LOB data, I have tried using the user-defined callback method, registering the callback function via OCIBindDynamic(). I initialize icbfps arguments as I would if I were dealing with RAW/LONG RAW data. When execution passes from the callback function, I encounter a memory exception within an Oracle dll. Where dvoid **indpp equals 0 and the object is of type RAW/LONG RAW, the function works fine. Is this not a valid methodology for CLOB/BLOB objects?
    Next, I tried performing piecewise INSERTs using OCIStmtGetPieceInfo() and OCIStmtSetPieceInfo(). When using this method, I use OCILobWrite() along with a user-defined callback designed for LOBs to send LOB data to the database. Here everything works fine until I exit the user-defined LOB write callback function where an OCI_INVALID_HANDLE error is encountered. I understand that both OCILobWrite() and OCIStmtExecute() return OCI_NEED_DATA. And it does seem to me that the two statements work separately rather than in conjunction with each other. So I rather doubt this is the proper methodology.
    As you can see, the correct method has evaded me. I have looked through the OCI LOB samples, but have not found any code that helps answer my question. Oracles OCI documentation has not been of much help either. So if anyone could offer some insight I would greatly appreciate it.
    Chris Simms
    [email protected]
    <HR></BLOCKQUOTE>
    null

  • Insert operation takes looooooooooong time

    One of our ETL procedures does an Insert operation on a table with the records selected from a couple of tables across DB link.
    While the SELECT query takes about 6 seconds to retrieve nearly 42,00,000 records, the insert of those records to a table takes about 45 minutes.
    Infact I've altered the table to NOLOGGING mode and the /*+ append */ comment(for Insert) is in place to reduce the redo logs.The destination table has no index and no constraints as well..
    Is there any other way that I can adapt to reduce the time of insert operation?
    Thanks,
    Bhagat

    >While the SELECT query takes about 6 seconds to retrieve nearly 42,00,000 records
    Is this in TOAD? If so, TOAD actually returns rows in sections and may not be returning the full set. You would have to actually scroll to the bottom of the grid and wait for the data to finish loading. Caution, if you did not select the option to execute queries in threads in TOAD you will not have the cancel query ability.
    >the insert of those records to a table takes about 45 minutes
    Have you performed a CREATE TABLE AS using the query. This will give you a good benchmark for performance during a direct-path load. You can then look at the USER_SEGMENTS.BYTES column for that table after a load and, with your timings, check the data transfer rate with your network support.

  • Inserting issue with MS Access

    Hi,
    I am trying to insert a record in MS Access. Following is the code.
    class SqlTest {
    public static void main(String args[]) throws Exception {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:myDsn");
    Statement stmt = con.createStatement();
    stmt.executeUpdate("insert into emp values('e999', 'Raj')");
    After executing the program, if I check the data base the record would not have been inserted. The program does not even throw any exception. If I execute the same program with ORACLE, it works fne and record gets inserted. Could some one please let me know what could be the problem?

    Hey guys,
    I also tried executing the query directly in MS Access and it just worked fine.
    Also I got work around for my problem. If I extract data after I insert it in the same program, then the record gets inserted. May be it has got do with COMMIT operation. But what if I have to do only INSERT operation without selecting data?

  • In operator and subquery

    I have created a sql query for oracle rdbms. I am passing a particular id in the subquery of my main query . I have one major difference in the query whenever i use a subquery with IN operator and using IN_list values in IN operator. I found that whenever after using IN operator with sub-query ,all the tables were going for full tablescan but if i used in_list values in the IN operator , all the required indexes were getting used.
    This is part of the query
    from ems_exception
    left outer join EMS_EXCEPTION_LINK_MAP
    on (ems_exception.ID = EMS_EXCEPTION_LINK_MAP.EXCEPTION_ID
    and ems_exception.id in  (SELECt ID
      FROM (SELECT  inner.*,ROWNUM rn
              FROM (SELECT /*+ UNNEST */ e.id,max(e.created_ts) aa
                        FROM ems_exception e
                        join ems_status_def
                        on ( e.status_id =ems_status_def.id and ems_status_def.id in (1,2,3))
                        join ems_exception_link_map
                       on (e.id = ems_exception_link_map.exception_id)
                       join ems_link
                       on (ems_link.id = ems_exception_link_map.link_id)
                       group by e.id 
                       order by aa desc
                       ) inner) outer
                       where outer.rn>=201 and outer.rn <=400 ))
    If i use values instead of the sub-query , the query plan was optimum . Is combination of IN operator and subquery bad in terms of query performance?

    It's not inherently bad - but it does depend on the optimizer getting  good estimate of the data volume.
    Did you test with 200 distinct values in your IN list, and can you see in the execution plan Oracle estimate of how many rows the subquery would generate.
    Regards
    Jonathan Lewis

  • Update/Insert Problem with Oracle Warehouse Builder

    Hello,
    i have update/insert problem with owb.
    Situation: I have a source-table called s_account and a target table called w_account_d. In the target table are already data which was filled trough the source table inserts. Now anyone make changes on data on the target table. This changes should now give further on the source table with an update operation. But exactly here is the problem i can´t map back the data to source because that will create a loop.
    My idea was to set a trigger but i can´t find this component in owb or is anywhere hidden?
    Also i have already seen properties as CDC or conditonal loading in the property inspector of the table, but i have no idea how it works.
    Give it other possibilities to modeling this case? or can anyone me explain how i can implement this eventually with CDC?
    I look forward for your replies :)

    Hi
    thanks for your answer. I follow your suggestion and have set the constraints of both tables into the database directly.Nevertheless it doesn´t work to begin. In the next step i found by right click on a table the listpoint "configure" - I goes to "unique key" --> creation method and set here follow options: Constraint State = ENABLE, Constraint Validation = Validate. That error message that appears before by the deployment disappears yet. Now i start the job to test if the insert/update process works right. Finally it seems to work - but not really.
    My Testscenario
    1. Load the data from source table about the staging area to data warehouse table: Check - it works!
    2. Change one data record in source table
    3. Load the source table with changed data record once again to staging area: Check - it works!
    4. Load new staging area table with the changed data record to data warehouse table: Check it works! BUT, BUT i can not recognize if it is insert or update operation, then under the design window by jobs execution windows is reported "rows selected 98", Rows inserted" is empty and "rows updated" is empty. So i think works not correct, then my opinion if it works correct it should show be "rows updated" 1.
    What can yet now still be wrong or forgotten? Any ideas?
    *By the way think not 98 rows there is not important if you make an update or insert which performance. It is an example table the right tables have million of records.*
    I look forward for your answers :)

  • Slow connect by prior ... start with subquery in 9i

    Has anyone come across a performance problem (compared to 8i) when using hierarchical queries where the START WITH list is generated by a subquery? The culprit seems to be an extra visit to the subquery block as part of the CONNECT BY WITH FILTERING operation.
    For example, take a simple tree structure:
    CREATE TABLE tree
    id NUMBER,
    parentid NUMBER
    CONSTRAINT tree_pk PRIMARY KEY (id)
    ...and a subquery - here just a table called sample with a subset of the ids from the tree table:
    CREATE TABLE sample
    id NUMBER,
    CONSTRAINT sample_pk PRIMARY KEY (id)
    ...with which to drive the start points of the treewalk:
    SELECT parentid, id, label
    FROM tree
    CONNECT BY PRIOR parentid = id
    START WITH id IN
    SELECT id FROM SAMPLE
    With the tables populated and analyzed, I get this from 8i:
    Execution Plan
    .0......SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=19)
    .1....0...CONNECT BY
    .2....1.....NESTED LOOPS (Cost=1 Card=1280 Bytes=10240)
    .3....2.......INDEX (FAST FULL SCAN) OF 'ID_PK' (UNIQUE) (Cost=1 Card=1280 Bytes=5120)
    .4....2.......INDEX (UNIQUE SCAN) OF 'TREE_PK' (UNIQUE)
    .5....1.....TABLE ACCESS (BY USER ROWID) OF 'TREE'
    .6....1.....TABLE ACCESS (BY INDEX ROWID) OF 'TREE' (Cost=2 Card=1 Bytes=19)
    .7....6.......INDEX (UNIQUE SCAN) OF 'TREE_PK' (UNIQUE) (Cost=1 Card=1)
    Statistics
    .....0..recursive calls
    .....4..db block gets
    .15687..consistent gets
    ....59..physical reads
    .....0..redo size
    223313..bytes sent via SQL*Net to client
    .38276..bytes received via SQL*Net from client
    ...343..SQL*Net roundtrips to/from client
    .....3..sorts (memory)
    .....0..sorts (disk)
    ..5120..rows processed
    and this is 9i:
    Execution Plan
    .0......SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=19)
    .1....0...CONNECT BY (WITH FILTERING)
    .2....1.....NESTED LOOPS
    .3....2.......NESTED LOOPS (Cost=2 Card=1280 Bytes=10240)
    .4....3.........INDEX (FAST FULL SCAN) OF 'ID_PK' (UNIQUE) (Cost=2 Card=1280 Bytes=5120)
    .5....3.........INDEX (UNIQUE SCAN) OF 'TREE_PK' (UNIQUE)
    .6....2.......TABLE ACCESS (BY USER ROWID) OF 'TREE'
    .7....1.....NESTED LOOPS
    .8....7.......BUFFER (SORT)
    .9....8.........CONNECT BY PUMP
    10....7.......TABLE ACCESS (BY INDEX ROWID) OF 'TREE' (Cost=2 Card=1 Bytes=19)
    11...10.........INDEX (UNIQUE SCAN) OF 'TREE_PK' (UNIQUE) (Cost=1 Card=20480)
    12....1.....INDEX (UNIQUE SCAN) OF 'SAMPLE_PK' (UNIQUE) (Cost=1 Card=1 Bytes=4)
    Statistics
    .....1..recursive calls
    .....1..db block gets
    .20525..consistent gets
    ....72..physical reads
    ...120..redo size
    224681..bytes sent via SQL*Net to client
    .38281..bytes received via SQL*Net from client
    ...343..SQL*Net roundtrips to/from client
    .....9..sorts (memory)
    .....0..sorts (disk)
    ..5120..rows processed
    ..so, about another 5000 logical reads, corresponding to the extra access of the sample table at the bottom of the query plan. So instead of just visiting the START WITH subquery once, to kick off the treewalk, I seem to be revisiting it for every row returned. Not too bad if that happens to be a unique index scan as here but that's not always the case.
    I know I've got new options for re-writing this as a join under 9i, I'm just curious about those extra lookups and why they're necessary.
    Cheers - Andrew

    There is undocumented parameter in Oracle 9i "_old_connect_by_enabled"
    which controls the behavoiur of hierarchy queries in 9i and above:
    You can try to return to 8i behaviour using it:
    SQL> SELECT parentid, id
      2  FROM tree
      3  CONNECT BY PRIOR parentid = id
      4  START WITH id IN
      5  (
      6  SELECT id FROM SAMPLE
      7  )
      8  /
    Execution Plan
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=1 Card=1 Bytes=26)
       1    0   CONNECT BY (WITH FILTERING)
       2    1     TABLE ACCESS (BY INDEX ROWID) OF 'TREE' (TABLE)
       3    2       NESTED LOOPS (Cost=2 Card=1 Bytes=26)
       4    3         TABLE ACCESS (FULL) OF 'SAMPLE' (TABLE) (Cost=2 Card
              =1 Bytes=13)
       5    3         INDEX (UNIQUE SCAN) OF 'TREE_PK' (INDEX (UNIQUE)) (C
              ost=0 Card=1 Bytes=13)
       6    1     NESTED LOOPS
       7    6       BUFFER (SORT)
       8    7         CONNECT BY PUMP
       9    6       TABLE ACCESS (BY INDEX ROWID) OF 'TREE' (TABLE) (Cost=
              1 Card=1 Bytes=26)
      10    9         INDEX (UNIQUE SCAN) OF 'TREE_PK' (INDEX (UNIQUE)) (C
              ost=1 Card=1)
      11    1     TABLE ACCESS (FULL) OF 'TREE' (TABLE) (Cost=1 Card=1 Byt
              es=26)
      12    1     INDEX (UNIQUE SCAN) OF 'SAMPLE_PK' (INDEX (UNIQUE)) (Cos
              t=1 Card=1 Bytes=13)
    SQL> alter session set "_old_connect_by_enabled" = TRUE;
    Session altered.
    SQL> SELECT parentid, id
      2  FROM tree
      3  CONNECT BY PRIOR parentid = id
      4  START WITH id IN
      5  (
      6  SELECT id FROM SAMPLE
      7  )
      8  /
    Execution Plan
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=1 Card=1 Bytes=26)
       1    0   CONNECT BY
       2    1     NESTED LOOPS (Cost=2 Card=1 Bytes=26)
       3    2       TABLE ACCESS (FULL) OF 'SAMPLE' (TABLE) (Cost=2 Card=1
               Bytes=13)
       4    2       INDEX (UNIQUE SCAN) OF 'TREE_PK' (INDEX (UNIQUE)) (Cos
              t=0 Card=1 Bytes=13)
       5    1     TABLE ACCESS (BY USER ROWID) OF 'TREE' (TABLE)
       6    1     TABLE ACCESS (BY INDEX ROWID) OF 'TREE' (TABLE) (Cost=1
              Card=1 Bytes=26)
       7    6       INDEX (UNIQUE SCAN) OF 'TREE_PK' (INDEX (UNIQUE)) (Cos
              t=1 Card=1)
    Rgds.

Maybe you are looking for

  • Mouse Clicks/Positons in Pictures!

    Even a guru learns new things... I just discovered the use of a picture control/indicator to detect mouse positions and clicks! What a wonderful thing. I have LabVIEW 6.0.2, and have, up to now, not known about this. To all those out there who I reco

  • Since updating to iOS 6 my 3GS will not work

    I recently updated to iOS 6 on my iphone 3GS, For a few days it has been fine, but today it started stating that I have 'No Service', which is strange. It then turned off when it got to 50% battery, and saying I needed to charge it. When I returned h

  • Can print over network, but scan over network doesn't work

    Scanner communication cannot be established from Windows 7 PC to 1536dnf MP. Printing from that computer is fine.  scanning from other computers over the network is fine also. I have uninstalled and reinstalled HP software, but that didn't fix the is

  • How to use dictation on ipad3

    can someone please tell me how I use the dictation feature when emailing from my ipad3  or sending a message / text ??? thanks

  • Provision from Process form

    I have a process form which has fileds like fname,lname and a lookup filed roles which queries the code decode key from the custom db table The fname and lname I can provision easily to the database table but with fname and lname I also need to provi