Insert Master Detail

Hi all,
I need to understand which is the fastest way for inserting rows in master-detail tables
Using a procedure. I often insert lots of details rows and sometimes master-details rows
Here there is my solution. Is there something faster?
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
CREATE TABLE MAIN_TRACING (
   MAINVAL VARCHAR2(10) NOT NULL,
   PAR1    VARCHAR2(10) NOT NULL);
CREATE TABLE TRACING_DET (
   MAINVAL   VARCHAR2(10) NOT NULL,
   SUBPAR1   VARCHAR2(10) NOT NULL);
CREATE UNIQUE INDEX MYPK ON MAIN_TRACING(MAINVAL);
ALTER TABLE MAIN_TRACING ADD ( CONSTRAINT MYPK PRIMARY KEY (MAINVAL) USING INDEX MYPK);
ALTER TABLE TRACING_DET ADD ( CONSTRAINT MYFK FOREIGN KEY (MAINVAL)  REFERENCES MAIN_TRACING (MAINVAL));
CREATE OR REPLACE PROCEDURE ADD_TRACE(V_MAINVAL VARCHAR2, V_PAR1 VARCHAR2, V_SUBPAR1 VARCHAR2)
AS
   PARENT_NOT_FOUND   EXCEPTION;
   PRAGMA EXCEPTION_INIT(PARENT_NOT_FOUND, -2291);
BEGIN
   INSERT INTO TRACING_DET(MAINVAL, SUBPAR1)
        VALUES (V_MAINVAL, V_SUBPAR1);
   COMMIT;
EXCEPTION
   WHEN PARENT_NOT_FOUND
   THEN
      INSERT INTO MAIN_TRACING(MAINVAL, PAR1)
           VALUES (V_MAINVAL, V_PAR1);
      INSERT INTO TRACING_DET(MAINVAL, SUBPAR1)
           VALUES (V_MAINVAL, V_SUBPAR1);
      COMMIT;
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.PUT_LINE(' Error code    : ' || TO_CHAR(SQLCODE));
END ADD_TRACE;
EXEC ADD_TRACE('m1', 'a', 'suba1');
EXEC ADD_TRACE('m1', 'a', 'suba2');
EXEC ADD_TRACE('m1', 'a', 'suba3');
--exec ADD_TRACE('m1', 'b', 'suba3'); --IMPOSSIBLE!
EXEC ADD_TRACE('m2', 'b', 'subb1');
EXEC ADD_TRACE('m2', 'b', 'subb2');
SELECT * FROM MAIN_TRACING;
MAINVAL    PAR1
m1         a
m2         b
SELECT * FROM TRACING_DET;
MAINVAL    SUBPAR1
m1         suba1
m1         suba2
m1         suba3
m2         subb1
m2         subb2

The answer (as Tom Kyte is fond of stating) is "It depends" ;-)
Is this something that is called scattered over the application? Most of the time it will be called with an existing MAINVAL and just sometimes now and again a new MAINVAL will be inserted? Subsequent calls to ADD_TRACE will typically have a different MAINVAL than the previous call?
If that is the case, then your method is not a bad one. Many programmers would have first tested for existence of master and decided whether to insert it or not, which would then be wasted effort in 95% of the cases.
Your method of assuming the master exists and then handle the exception if it does not - that is quite neat. But the key is - it has to be the exception to the rule that the exception handler is invoked.
But if on the other hand you are calling ADD_TRACE pretty consecutively (sort of like your example) with first several calls with one MAINVAL, then several calls with a new MAINVAL, then several with a new MAINVAL, etc. - say a typical ETL process or loading data from perhaps a flatfile or something like that - then you would do better to do one insert of the parent and then bulk up the children in a bulk insert.
So it depends on your use case. There is not one generally best way to insert into master-detail - there will be several depending on whether you are bulk loading data to your master-detail or you have scattered calls.
But just one other thing concerning your code:
Usually it is not a good idea to issue those COMMIT statements inside your procedure. How do you know if the caller has finished with the transaction or not?
Either let the client/caller decide when the complete transaction is done.
Or you may decide that this is tracing/logging and should be logged no matter whether the calling transaction commits or rollbacks, and then you can make ADD_TRACE use an autonomous transaction.
(All of the above is just my personal opinion and you will likely find other people with different opinions ;-) )

Similar Messages

  • Spry insert master/detail layout Can't get more than two columns?

    Ive been trying to get more than two columns just experimenting with spry data sets and can't with the layout option "insert master/detail layout"
    What am I doing wrong?
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:spry="http://ns.adobe.com/spry">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script src="SpryAssets/SpryData.js" type="text/javascript"></script>
    <script src="SpryAssets/SpryHTMLDataSet.js" type="text/javascript"></script>
    <link href="SpryAssets/SpryMasterDetail.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
    var ds1 = new Spry.Data.HTMLDataSet("benefitsdata.html", "bizben", {firstRowAsHeaders: false});
    </script>
    </head>
    <body>
    <div align="center">
      <div class="MasterDetail">
        <div spry:region="ds1" class="MasterContainer">
          <div class="MasterColumn" spry:repeat="ds1" spry:setrow="ds1" spry:hover="MasterColumnHover" spry:select="MasterColumnSelected">{column0}</div>
        </div>
        <div spry:detailregion="ds1" class="DetailContainer">
          <div class="DetailColumn">{column1}</div>
          <div class="DetailColumn">{column2}</div>
          <div class="DetailColumn">{column3}</div>
        </div>
        <br style="clear:both" />
      </div>
    </div>
    </body>
    </html>

    Hello,
    in addition to Sudarshan's statement about the discontinued support: In my SPRY library I found this "html_dataset_sample". Maybe it could help you. Here the source code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:spry="http://ns.adobe.com/spry">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Untitled Document</title>
    <script src="SpryAssets/SpryData.js" type="text/javascript"></script>
    <script src="SpryAssets/SpryHTMLDataSet.js" type="text/javascript"></script>
    <script type="text/javascript">
    <!--
    var ds1 = new Spry.Data.HTMLDataSet("benefitsdata.html", "bizben", {firstRowAsHeaders: false, useCache: false, tableModeEnabled: false, sortOnLoad: "column0", sortOrderOnLoad: "ascending", rowSelector: "tr.destroyed", dataSelector: "td"});
    ds1.setColumnType("column2", "number");
    ds1.setColumnType("column3", "number");
    ds1.setColumnType("column4", "number");
    //-->
    </script>
    </head>
    <body>
    <div spry:region="ds1">
    <table>
      <tr align="center" valign="middle">
       <th width="100" spry:sort="column0">Name</th>
        <th width="100" spry:sort="column1">Class</th>
       <th width="100" spry:sort="column2">Length(m)</th>
       <th width="100" spry:sort="column3">Crew Size</th>
       <th width="100" spry:sort="column4">Crew 1</th>
    </tr>
      <tr align="center" valign="middle" spry:repeat="ds1">
       <td width="100"><p>{column0.1}{column0.2}{column0.3}</td>
         <td width="100">{column1}</td>
       <td width="100">{column2}</td>
       <td width="100">{column3}</td>
       <td width="100">{column4}</td>
    </tr>
      </table>
    </div>
    </body>
    </html>
    Hans-Günter

  • BC4J - Inserting Master/Detail records in same transaction.

    I know this is possible, but I seem to be missing something to allow it to happen within BC4J.
    I'm creating a RowSet off of a View Object and inserting new Rows into this RowSet. This RowSet represents my child/detail records for insert into a child table.
    I then create a new Row off of another View Object. This row represents my Master/parent record for insert into a parent table.
    All of the above is being done in the same applicationModule transaction with locking mode set to Optimistic.
    Before I commit the transaction, I grab the next sequence # to use as the primary key for the master record and the foreign key for the child records. I apply those to the newly created child rows and the newly created master row.
    However, when I commit I continue to get a JBO-26041: Failed to post data to database during "Insert": error due to ORA-02291: integrity constraint (CUST_LICENSES_FK4) violated - parent key not found
    If everything was created in the same transaction, why won't this allow me to insert into both tables with the correct primary/foreign keys? It's almost as if the child records are being inserted first prior to the parent record.
    Any ideas?
    Thanks in advance..
    Teri Kemple
    TUSC
    [email protected]

    However, when I commit I continue to get a JBO-26041: Failed to post data to database during "Insert": error due to ORA-02291: integrity constraint (CUST_LICENSES_FK4) violated - parent key not found
    If everything was created in the same transaction, why won't this allow me to insert into both tables with the correct primary/foreign keys? It's almost as if the child records are being inserted first prior to the parent record.This is due to the order of rows being posted. In this case it seems the detail row is getting posted before the master.
    To avoid such situations, either you may implement your own post ordering by making sure that when a detail is to
    be inserted, it's master is inserted or you may use "Composition Association" flag in the association wizard between
    the master and the detail entities to let the framework manage a tight composition relationship between the two entity
    types. BTW, there was another definitive thread recently on inserting master-detail in the
    same transaction, but the forum search engine is so useless I can't find it. Anyone
    have the msgid handy or know how to find that thread again??
    FYI: the help describes the Composition flag functionality in terms of the Master record already existing in the DB. In our problem here, the Master is being inserted in the same transaction. Thus needs to be posted FIRST.
    I got a integrity constraint exception too, then set the composition flag and now I get:
    500 Internal Server Error
    oracle.jbo.InvalidOwnerException: JBO-25030: Failed to find or invalidate owning entity.
         void oracle.jbo.server.EntityImpl.create(oracle.jbo.AttributeList)
         void gov.ga.gdc.otf.bc.JotfWithdrawalsImpl.create(oracle.jbo.AttributeList)
         void oracle.jbo.server.ViewRowStorage.create(oracle.jbo.AttributeList)
         void oracle.jbo.server.ViewRowImpl.create(oracle.jbo.AttributeList)
         oracle.jbo.server.ViewRowImpl oracle.jbo.server.ViewObjectImpl.createInstance(oracle.jbo.server.ViewRowSetImpl, oracle.jbo.AttributeList)
         oracle.jbo.server.RowImpl oracle.jbo.server.QueryCollection.createRowWithEntities(int[], oracle.jbo.server.EntityImpl[], oracle.jbo.server.ViewRowSetImpl, oracle.jbo.AttributeList)
         oracle.jbo.Row oracle.jbo.server.ViewRowSetImpl.createRowWithEntities(int[], oracle.jbo.server.EntityImpl[], oracle.jbo.AttributeList)
         oracle.jbo.Row oracle.jbo.server.ViewRowSetImpl.createRow()
         oracle.jbo.Row oracle.jbo.server.ViewObjectImpl.createRow()
         void gov.ga.gdc.otf.appmodule.JOtfOffenderAppModuleImpl.insertWithdrawal(java.lang.String, java.lang.String, java.math.BigDecimal, oracle.jbo.domain.Number, java.lang.Integer, int)
         void gov.ga.gdc.otf.appmodule.JOtfOffenderAppModuleImpl.payOneObligation(java.lang.String, java.lang.String, java.lang.Integer, oracle.jbo.domain.Number, java.math.BigDecimal, int)
         void gov.ga.gdc.otf.appmodule.JOtfOffenderAppModuleImpl.payObligations(java.lang.String, java.lang.String, java.math.BigDecimal, oracle.jbo.domain.Number)
         void gov.ga.gdc.otf.appmodule.JOtfOffenderAppModuleImpl.receiveFunds(java.lang.String, java.lang.String, int, java.math.BigDecimal, java.lang.String, java.lang.String, java.lang.String, java.math.BigDecimal, long)TIA much! curt

  • TooManyObjectsException inserting master-detail composed entities

    Hi all,
    I have read something similar in the blog, but I can't solve my problem.
    I am using JDev 11.1.1.0.2 and I have thi situation:
    1) a page where I can edit data, and pushing a button I can create a new record
    2) clicking on this button, starts a bounded task-flow (train) where I insert master (before) and detail (after) data.
    I have checked composition flag in the associations that links the two entities
    When I try to commit I have this error:
    oracle.jbo.TooManyObjectsException: JBO-25013: Too many objects match the primary key oracle.jbo.Key[... ].
         at oracle.jbo.server.EntityCache.throwTooManyObjectsException(EntityCache.java:431)
         at oracle.jbo.server.EntityCache.addForAltKey(EntityCache.java:818)
         at oracle.jbo.server.EntityCache.add(EntityCache.java:404)
         at oracle.jbo.server.ViewRowStorage.entityCacheAdd(ViewRowStorage.java:2551)
         at oracle.jbo.server.ViewRowImpl.entityCacheAdd(ViewRowImpl.java:3139)
         at oracle.jbo.server.QueryCollection.populateRow(QueryCollection.java:2911)
         at oracle.jbo.server.QueryCollection.fetch(QueryCollection.java:2764)
         at oracle.jbo.server.QueryCollection.get(QueryCollection.java:1931)
         at oracle.jbo.server.ViewRowSetImpl.getRow(ViewRowSetImpl.java:4508)
         at oracle.jbo.server.ViewRowSetIteratorImpl.doFetch(ViewRowSetIteratorImpl.java:2899)
         at oracle.jbo.server.ViewRowSetIteratorImpl.ensureRefreshed(ViewRowSetIteratorImpl.java:2755)
         at oracle.jbo.server.ViewRowSetIteratorImpl.refresh(ViewRowSetIteratorImpl.java:2996)
         at oracle.jbo.server.ViewRowSetImpl.notifyRefresh(ViewRowSetImpl.java:2453)
         at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:1047)
         at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:873)
         at oracle.jbo.server.ViewRowSetIteratorImpl.ensureRefreshed(ViewRowSetIteratorImpl.java:2738)
         at oracle.jbo.server.ViewRowSetIteratorImpl.ensureRefreshed(ViewRowSetIteratorImpl.java:2715)
         at oracle.jbo.server.ViewRowSetIteratorImpl.getAllRowsInRangeInternal(ViewRowSetIteratorImpl.java:2101)
         at oracle.jbo.server.ViewRowSetIteratorImpl.getAllRowsInRange(ViewRowSetIteratorImpl.java:2148)
         at oracle.jbo.server.ViewRowSetImpl.getAllRowsInRange(ViewRowSetImpl.java:2730)
         at oracle.jbo.server.ViewObjectImpl.getAllRowsInRange(ViewObjectImpl.java:9131)
         at oracle.jbo.server.ViewRowSetImpl.findByViewCriteriaWithBindVars(ViewRowSetImpl.java:5191)
         at oracle.jbo.server.ViewRowSetImpl.findByViewCriteria(ViewRowSetImpl.java:4950)
         at oracle.jbo.common.AbstractListBinding.filterList(AbstractListBinding.java:580)
         at oracle.jbo.common.AbstractListBinding.filterList(AbstractListBinding.java:470)
         at oracle.jbo.server.RowImpl.applyListBindings(RowImpl.java:901)
         at oracle.jbo.server.RowImpl.checkAndApplyListBindings(RowImpl.java:601)
         at oracle.jbo.server.ViewObjectImpl.afterRowUpdate(ViewObjectImpl.java:11240)
         at oracle.jbo.server.ViewObjectImpl.sourceChanged(ViewObjectImpl.java:11492)
         at oracle.jbo.server.EntityCache.sendEvent(EntityCache.java:1150)
         at oracle.jbo.server.EntityCache.deliverEntityEvent(EntityCache.java:1164)
         at oracle.jbo.server.EntityCache.notifyColumnAndBlgChange(EntityCache.java:1220)
         at oracle.jbo.server.EntityImpl.notifyAttributesChanged(EntityImpl.java:6781)
         at oracle.jbo.server.EntityImpl.notifyAttributesChanged(EntityImpl.java:6762)
         at oracle.jbo.server.EntityImpl.populateAttribute(EntityImpl.java:6486)
         at oracle.jbo.server.EntityImpl.refreshFKInNewContainees(EntityImpl.java:5575)
         at oracle.jbo.server.OracleSQLBuilderImpl.doEntityDML(OracleSQLBuilderImpl.java:514)
         at oracle.jbo.server.EntityImpl.doDML(EntityImpl.java:7779)
         at oracle.jbo.server.EntityImpl.postChanges(EntityImpl.java:6162)
         at oracle.jbo.server.DBTransactionImpl.doPostTransactionListeners(DBTransactionImpl.java:3253)
         at oracle.jbo.server.DBTransactionImpl.postChanges(DBTransactionImpl.java:3061)
         at oracle.jbo.server.DBTransactionImpl.commitInternal(DBTransactionImpl.java:2180)
         at oracle.jbo.server.DBTransactionImpl.commit(DBTransactionImpl.java:2382)
         at oracle.adf.model.bc4j.DCJboDataControl.commitTransaction(DCJboDataControl.java:1565)
         at oracle.adf.model.binding.DCDataControl.callCommitTransaction(DCDataControl.java:1407)
         at oracle.jbo.uicli.binding.JUCtrlActionBinding.doIt(JUCtrlActionBinding.java:1293)
         at oracle.adf.model.binding.DCDataControl.invokeOperation(DCDataControl.java:2126)
         at oracle.jbo.uicli.binding.JUCtrlActionBinding.invoke(JUCtrlActionBinding.java:697)
         at oracle.adf.controller.v2.lifecycle.PageLifecycleImpl.executeEvent(PageLifecycleImpl.java:392)
         at oracle.adfinternal.view.faces.model.binding.FacesCtrlActionBinding._execute(FacesCtrlActionBinding.java:159)
         at oracle.adfinternal.view.faces.model.binding.FacesCtrlActionBinding.execute(FacesCtrlActionBinding.java:118)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.el.parser.AstValue.invoke(AstValue.java:157)
         at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
         at org.apache.myfaces.trinidadinternal.taglib.util.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:53)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodBinding(UIXComponentBase.java:1227)
         at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:183)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:70)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:274)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:74)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:70)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:274)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:74)
         at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:458)
         at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:763)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._invokeApplication(LifecycleImpl.java:640)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:275)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:175)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:181)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:85)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:279)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._invokeDoFilter(TrinidadFilterImpl.java:239)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:196)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:139)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at oracle.security.jps.wls.JpsWlsFilter.doFilter(JpsWlsFilter.java:102)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:65)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(Unknown Source)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

    I have solved.
    I have to flag the composition association in the entity object

  • PLSQL logic to insert master detail records

    Hi All
    I have a requirement where I need to do the following.
    1: Have a headers and details table for some data that I need to insert
    2: Transactions need atomicity...ie If the header record fails then the details should still be inserted , but with an Error flag
    3: Needs good error handling
    I'm trying to come up with some logic like so
    1: Have a header cursor and a details cursor
    2: Have the lines for loop inside the headers for loop and then do the inserts
    3: If an exception is thrown for one record it should not error out the other records(this can be done with a begin end block)
    Does anyone have a better idea for this...Is it an efficient way of developing header- detail inserts?
    If someone has an example that I can go over I would appreciate that or a basic algorithm would do too..
    Thanks
    D

    851866 wrote:
    1: Have a headers and details table for some data that I need to insert
    2: Transactions need atomicity...ie If the header record fails then the details should still be inserted , but with an Error flagThis is the opposite of atomicity, what you describe is called data corruption.
    3: Needs good error handlingGood error handling is specific to the expected error and is defined by the specific business requirements.
    1: Have a header cursor and a details cursor
    2: Have the lines for loop inside the headers for loop and then do the inserts
    3: If an exception is thrown for one record it should not error out the other records(this can be done with a begin end block)
    Does anyone have a better idea for this...Is it an efficient way of developing header- detail inserts?No, using a cursor loop is as inefficient as possible.
    If someone has an example that I can go over I would appreciate that or a basic algorithm would do too..If you provide an example of the error you expect and what you are supposed to do in that situation then it is possible someone could provide an example algorithm.

  • Inserting XML(Master Detail like PO)into Database

    hi,
    Can any one suggest me which tools or what methodolgy I should use to insert master detail data like one header and multiple rows into database.
    I am unable to insert into database through object view with the help of XML SQL utility for Java.
    Please help in this....
    null

    Here's an example that ships with
    the XSQL Servlet release 0.9.8.6
    (due out any day now on OTN!!)
    With this set of types and object view
    you can insert documents like the
    example at the end that is REM'd out.
    drop view department;
    drop type dept_t;
    drop type emp_list;
    drop type emp_t;
    create or replace type emp_t as object (
    empno number,
    ename varchar2(80),
    sal number
    create or replace type emp_list as table of emp_t;
    create or replace type dept_t as object (
    deptno number,
    dname varchar2(80),
    loc varchar2(80),
    employees emp_list
    create or replace view department of dept_t
    with object OID (deptno)
    as select deptno, dname, loc,
    cast(multiset(select empno, ename, sal
    from emp
    where emp.deptno = dept.deptno
    ) as emp_list ) employees
    from dept;
    create trigger department_ins
    instead of insert on department
    for each row
    declare
    emps emp_list;
    emp emp_t;
    begin
    -- Insert the master
    insert into dept( deptno, dname, loc )
    values (:new.deptno, :new.dname, :new.loc);
    -- Insert the details
    emps := :new.employees;
    for i in 1..emps.count loop
    emp := emps(i);
    insert into emp(deptno, empno, ename, sal)
    values (:new.deptno, emp.empno, emp.ename, emp.sal);
    end loop;
    end;
    REM
    REM
    REM <ROWSET>
    REM <ROW>
    REM <DEPTNO>99</DEPTNO>
    REM <DNAME>ACCOUNTING</DNAME>
    REM <LOC>NEW YORK</LOC>
    REM <EMPLOYEES>
    REM <EMPLOYEES_ITEM>
    REM <EMPNO>1111</EMPNO>
    REM <ENAME>CLARK</ENAME>
    REM <SAL>2450</SAL>
    REM </EMPLOYEES_ITEM>
    REM <EMPLOYEES_ITEM>
    REM <EMPNO>2222</EMPNO>
    REM <ENAME>KING</ENAME>
    REM <SAL>5000</SAL>
    REM </EMPLOYEES_ITEM>
    REM <EMPLOYEES_ITEM>
    REM <EMPNO>3333</EMPNO>
    REM <ENAME>MILLER</ENAME>
    REM <SAL>1300</SAL>
    REM </EMPLOYEES_ITEM>
    REM </EMPLOYEES>
    REM </ROW>
    REM </ROWSET>
    null

  • Master & Detail Pages

    Hello all,
    I am asking for help on creating Master - Detail pages. I am using Wamp version 2. Database name "TestingCo" with 3 tables:
    Users:      user_id                int(4)           Primary_Key
                   user_fname          varchar(30)
                   user_lname          varchar(30)
                   user_license_id    int(4)
                   user_pix_id          int(4)
    Licenses: license_id           int(4)             Primary_Key
                   license_no          varchar(10)
    Pictures:  pix_id                 int(4)             Primary_Key
                   pix_url                varchar(50)
    1. I create a recordset called: rsMasterDetail:
         * with all fields from all 3 tables.
         * Where users.user_pix_id = pictures.pix_id AND users.user_license_id = licenses.license_id
         * Order By users.urser_fname
    2. On Master page, I insert Master Detail Page Set:
         * Master page fields: All fields from rsMasterDetail recordset.
         * Link to Detail from: user_id          / later I tried: user_fname         
         * Pass unique key:   user_id          / later I tried: one by one from each field of Users table.
         * Show: All records
         * Detail page name:     Detailpage.php
         * Detail page fields:     All from rsMasterDetail recordset.
    3. Result: (I always get the same result as below).
         * Masterpage.php - perfect - All correct display between 3 relational tables
         (*) Detailpage.php - when I click on any link from the Masterpage.php:
              - All the fields from Users table are displayed correctly depending on which link I clicked on Masterpage.php
              (+) The fields from table Licenses are displayed the first row only (1st record of the table.)???????????????
              (+) The fields from tabel Pictures are displayed the first row only???????????????
    A. When I built the rsMasterDetail recordset, I test it and the result is good.
    B. The masterpage.php shows all fields in perfect order.
    There must be something wrong when the information passes from Master page to Detail page!??!!???
    Please help me!
    Thank you

    Hi Lon,
    When I test it, the tables relationship is perfect since all three tables line up correctly on the masterpage.php. If there is problem with tables relationship, I should also have such problem with the masterpage.php.
    I, once tried to build another recordset called: rsTest. This time I had only 2 tables: Users and Licenses. The result was the same; only the first row of the licenses table would show on the detailpage.php; while the masterpage.php the rows on both tables line up correctly.
    I have tried many ways to find solutions unsuccessfully. What I get so far is:
    * The recordset is display correctly every single time when I click the "Test" button, as well as on the masterpage.php (I meant the tables relationship).
    * When the link on the masterpage.php is clicked, the detailpage.php supposes come up and display all rows of 3 tables of the linked record. However, all rows of the 1st table are correctly displayed, and the other table(s) only show its first row regardless which link on the Masterpage.php was clicked.
    I hope you and others gurus can help me out.
    I appreciate your help.

  • How to create Insert & Update on master-detail form JPA/EJB 3.0

    Is there any demonstration or tips how to Insert record on master-details form for JPA/EJB 3.0 with ADF binding?

    I have master-detail forms (dept-emp). I drag the dept->operations->create method to JSF page. But when I click create button, only dept form is clear and ready for insert. But emp form is not clear. How can I add create method for this?
    Can you give some example how to pass the right object to the persist or merge method so that it can save both the two objects (master-detail tables)
    Thanks
    Edited by: user560557 on Oct 9, 2009 8:58 AM

  • How can I insert in the table detail of a master/detail form??

    Hello, I have created a master/detail form from the assistant, and with the code generated by APEX I do not manage to insert a row in the table detail, I press the button 'Add Row' and refill information, when I press the button ' to apply changes ' me the following mistake appears:
    'Error in mru internal routine: ORA-20001: Error in MRU: row= 1, ORA-20001: ORA-20001: Current version of data in database has changed since user initiated update process. current checksum = "C85B64D53C8D63E9D3EE83B82728DFA3", item checksum = "244B1FED90DF5CC5B0DDB6728F4D02DD"., update "CRM_ADMIN"."ASIGNACIONES_AM_CONTACTOS" set "SECUENCIA" = :b1, "CODIGO" = :b2, "NOMBRE_CLIENTE" = :b3, "NOMBRE" = :b4, "COMENTARIOS" = :b5, "CODIGO_COMERCIAL" = :b6'
    How I can solve and be able to insert in the table it detail?
    Thanks

    Hi Law,
    Text in a shape or a text box will not feature in the table of contents.
    To get a colour behind your titles, type them into your document (not a shape). Format as Heading or some other paragraph style the TOC will recognise.
    Select the title text and Format Panel > Text > Font > Gearwheel > Advanced Options.
    Choose Character Fill Color and choose a colour from the palette (left) or colour circle (right).
    Example Titles (all on the same page for a smaller screen shot).
    Chapter 3 (in a coloured Text Box or Shape) does not appear in the TOC:
    Hint for cheats :
    To give the titles a wider Character Fill Colour, add some Tab characters before and after.
    Regards,
    Ian.

  • Insert Record in Master-Detail block

    I am using JDev 10.1.2, Struts, ADF and JSP
    I have a Master-Detail relationship. As the master table(Course) is browsed , the details(Students) record keep changing. Now I want to insert records to the detail (Students) block alone. I am generating the Students id using Sequence, but I want use the Course Id that is being browsed for the new record inserted. How do I do this.
    I used the 'Read Only Dynamic Table' for the Details table and used the create button and forward it to create jsp. When I click on create button, it does go to the create jsp, but the the row is not blank. what do I have to do.
    Any help will be appreciated.

    Hi Shay,
    Thanks for the response. At least I'm getting some response after so long a time.
    I'm not sure what are you looking at. But this is what I have.
    I have a browseCourse.jsp that displays the courses in the master and students in the detail. I have a create button for the detail, and my code looks like this.
    public class BrowseCourseAction extends DataForwardAction
    public void onCreate (DataActionContext actionContext)
    actionContext.getHttpServletRequest().getSession().setAttribute("type", "create");
    if (actionContext.getEventActionBinding() != null)
    actionContext.getEventActionBinding().doIt();
    actionContext.setActionForward("createstudent");
    when the user click on create button it shows the createstudent.jsp. My question is how to set the course id for the new student that is about to be created.
    What do I have to do for this?

  • Insert error in master-detail form

    Probably a stupid question. When I populate the master block of
    a master detail form from an LOV, I am asked to save the form.
    Since the information is loaded from the LOV, there are no
    changes to save. If I answer yes, it gives an Insert error due
    to the primary key violation in the master block table. If I
    answer no, it opens the detail block and gives the correct
    information. The problem is that when I enter information into
    the detail block and try to save it, I get the same error
    message regarding the primary key violation in the master block.
    The form works fine if I do not populate the master block from
    the LOV (or from select statements in triggers). Any suggestions
    will be appreciated.
    LS

    Hi,
    Check for the form or block status.Looks like the status has
    changed.Thats why u r getting the message.If any of the base
    table item has changed then u will get such a message.Try
    working on this an check it out.
    Thanks
    Vinod

  • Insert in master-detail

    Hello all,
    I'm having a problem with an insert in a master detail. Situation is as follows:
    I have a VO based on an entity, VOMaster. This has a ViewLink to another VO based on an entity (1..*), VODetail. In my application, I do a CreateInsert on VOMaster. All works well, I can edit the fields there and I could do a commit if I want to.
    But I don't want to commit just yet. I now want to CreateInsert a row of VODetail. When I do that, I either get nullpointer exceptions because the row isn't actually created (when I uncheck the composition chexbox in the Association between the 2 entities), or I get an InvalidOwnerException (when that checkbox is checked).
    I also tried to not do a CreateInsert but a Create, but then the fields are not editable.
    Can anybody help me?
    Many thanks!

    On a side note: I tried http://radio.weblogs.com/0118231/stories/2003/01/17/whyDoIGetTheInvalidownerexception.html but I get the same errors (InvalidOwner on .createRow())...

  • Inserting records in master detail form

    I am moving an existing Webdb Application to portal. In the application there is a master detail form along the following lines
    Dept Id: 10
    Dept Name: IMS
    Employee ID Employee Name etc
    1586 Julie Wilks
    Currently users can insert/update/delete detail lines. When inserting, the dept_id foreign key is automatically inserted into the dept_id column in the detail table. My understanding is that for some reason this does not happen in portal. Instead, the user is expected to input any foreign keys manually. As this could lead to all sorts of problems I'd rather not have to do this.
    Has anyone found a means to get around this problem?
    If solutions have already been posted, please point me in the right direction as a search on the forum hasn't come up with anything.
    Many thanks,
    Julie Wilks

    Hi,
    Am I the only one having this problem?
    Thanks,
    Diana

  • Master-detail page with form layout -- insert only -- not in create mode

    JDeveloper 10.1.3.1 with JHeadstart
    I have the following master-detail structure in JHeadstart:
    Group 1, Table a, Layout: table-form
    Group 2, Table b, Layout: table-form
    Group 3, Table c, Layout: form
    Group 4, Table d, Layout: form (on same page as master table c)
    Table a, b and c are updatable (insert, update and delete).
    I have problems with the last page, tables c and d, master-datail both in form layout.
    The master-table (c) is not an insert-only table, the detail table needs to be an insert-only form on the same page as the master table c.
    Settings Table d:
    Advanced search and quick search: none
    Autoquery: disabled
    Single row insert allowed (other options in Operations disabled)
    In my view object I have used the settings in the JDeveloper guide 8.1.2 ('no rows...' in tab Tuning).
    I run my application in JDeveloper (with the option run in my ViewController-project, which means that I am not running my detail page directly in JDeveloper??) and when I open this last page, the detail form is not in create mode (I see no rows found and a create rows button).
    I have read several threads in this forum, but I do not know how to solve this problem.

    This does not work.
    In my first post I made an mistake in describing my application, it is not a table-form, but a tree-form application:
    Group 1, Table a, Layout: tree-form
    Group 2, Table b, Layout: tree-form
    Group 3, Table c, Layout: tree-form
    Group 4, Table d, Layout: form (on same page as master table c)
    If I override the executeQueryForCollection method in the ViewObjectImpl of table d I get a message ('JBO-27122: SQL-fout tijdens voorbereiding van statement' and 'java.sql.SQLException: OALL8 is in an inconsistent state').
    while clicking on the tree (with table b and c). It seems that the QueryForCollection method is being executed to early.

  • Multi-row insert in master-detail tables

    Hi, I'm using jdev 10.1.3.2 with jheadstart and my problem is:
    I hava a master-detail structure, both are tables and my goal is that I want multi insert (exactly 3) in master and detail table when user makes new order(some business scenario). I cannot create rows in master or detail VO by overriding create() method because its entities have complex primary keys and some part of this key is populated by the user with lov. So I set in jhs new rows to 3 and checked multi-row insert allowed but the problem is that overall I can only create rows in master table after I submit form. I want to create row in master table and fill rows in detail table, and after that I want to have opportunity to create second (or even third) row in master table and fill rows in detail table.
    thanks for help.
    Piotr

    See JHS DevGuide: 3.2.1. Review Database Design:
    If you are in the position to create or modify the database design, make sure all
    tables have a non-updateable primary key, preferably consisting of only one
    column. If you have updateable and/or composite primary keys, introduce a
    surrogate primary key by adding an ID column that is automatically populated.
    See section 3.2.4 Generating Primary Key Values for more info. Although ADF
    Business Components can handle composite and updateable primary keys, this
    will cause problems in ADF Faces pages. For example, an ADF Faces table
    manages its rows using the key of the underlying row. If this key changes,
    unexpected behavior can occur in your ADF Faces page. In addition, if you want
    to provide a drop down list on a lookup tables to populate a foreign key, the
    foreign key can only consists of one column, which in turn means the referenced
    table must have a single primary key column.
    Groeten,
    HJH

Maybe you are looking for

  • Hotspot Click is not working !!

    Hi, I have sucessfully implemented hotspot click using OOALV. I still have an issue in one of the hotspot click feature. I have a OOALV report where i have implemented hotspot click for Contract # as when 'KONNR'.         if w_listdata-konnr <> ''.  

  • R12.1.1 receivable module create a Organization as a customer

    Hi Friends I am going to implement R12.1.1 receivable module. I have already implemented same version GL module. Now I am working R12.1.1 vision server to initial implement of AR module but I am getting an error when I am going to create Organization

  • R/3 Enterprise migration required to migrate EP 6.0 SP2?

    We currently have R/3 Entprise Core 4.7 installed, w/Ext Set 1.10, and are running Enterprise Portal 6.0 SP2 with the J2EE 6.20 Engine. Can we install Netweaver 2004s and migrate EP 6.0 SP2 to the current release (in order to take advantage of the We

  • Enhanced FlexWAN Module

    I have an Enhanced FlexWAN module in a 6509. I need to swap out one of the port adapters. What part of this is hot-swappable? Can the PA's be removed while the mod is in and switch on? Or is just the mod removable? Thanks in advance.

  • How to repeat depreciation run for fixed assets

    Dear Sir(s), we are on SAP B PL03. We would like to re-run depreciation for some fixed assets to correct a previous depreciation run which was executed by mistake. The depreciation was posted to the GL accounts. We are not able to get this option of