Child Records getting inserted before Parent

HI All,
I have an Entity object (Vendors) that has a defined relationship to payments (12 months) when I create a new vendor record I'm creating the 12 child records that all works fine but when I try to issue a commit the child records get inserted first creating a constraint error. If I turn the constraint off and using the "Jbo.debugoutput=console" I can see the 12 months being inserted followed by the vendor record. The payment records vendor_id is being set to the correct parent but the insert is happing in the wrong order does anybody know how to control the order of the insert. There's a Association set between the Vendor entity and the payment entity. If I move the code to a view object it seems to work fine. But in this case we have multiply view objects on these entity objects and I'm trying to prevent having to write the same code in every view Object.
Here's the code for the Create on the Vendors EntityImpl
protected void create(AttributeList attributeList) {
super.create(attributeList);
// Set the default values and the Seq number for this new record
SequenceImpl seqNoImpl = new SequenceImpl("VENDORS_SEQ",getDBTransaction());
this.setVendorId( seqNoImpl.getSequenceNumber());
Number zeroAmt = new Number(0);
RowIterator paymentsIter = this.getVendorPayments();
// When creating a new Vendor create the 12 months of payment records
for (int i = 1; i < 13; i++) {
Row newRow = paymentsIter.createRow();
newRow.setAttribute("Month",i);
newRow.setAttribute("Amount",zeroAmt);
paymentsIter.insertRow(newRow);
Dose anybody have any ideas....

Pieter,
Thanks for the information!!
Using it I was able to get the process working. There where some interesting side affects. If I just turned on the "Composition Association" then no payment records got inserted into the database even though they where in the entity and view objects. I took the second recommendation of adding code to the PostChanges event and was able to get the parent and children inserted in the correct order.
Thanks again for the idea and information

Similar Messages

  • To find all the child records are processed before parent records

    Hi,
    When i am trying to process consignment pulls and my client is using third party tool to insert the data into interface tables. My logic is written in such a way that it should pick parent record associated with child but there is some delay in child records and not all the child records are being pulled with parent.
    In a brief, i need to write a condition in such a way that my parent cursor should pick all the child records with max(last_updated_date) and then it should be processed.
    eg: I have a family and need to catch bus with all my family members. I need to check now for the last family member who get into and should wait for atleast 2mins so as to ensure all my family members are in. I am unable to achieve this with count. Please do revert back soon.
    Details are below:
    CURSOR c_pull (p_pull_id NUMBER) IS----------------------------------parent cursor
    SELECT ecp.ROWID ROW_ID
    ,ecp.*
    FROM consignment_pulls ecp
    WHERE ecp.process_flag IN ( 2, 3 )
    AND ecp.pull_id > NVL(p_pull_id,0)
    ORDER BY ecp.pull_id
    FOR UPDATE OF ECP.PROCESS_FLAG NOWAIT;
    CURSOR c_line (p_pull_id NUMBER) IS----------------------------------child cursor
    SELECT ecpi.ROWID ROW_ID
    ,ecpi.*
    FROM consignment_pull_items ecpi
    WHERE ecpi.process_flag IN ( 2, 3 )
    AND ecpi.pull_id = p_pull_id
    FOR UPDATE OF ecpi.process_flag;
    Edited by: Prathyusha on Apr 5, 2012 12:07 AM
    Edited by: jerry on Apr 5, 2012 12:10 AM

    Hi Helios,
    Thanks for the info. But its not a concurrent request something like we can filter with start date and completion date. Its all about selection of records from headers and lines table and not able to make those selection of header records with a delay of say some 2minutes until all the child records are inserted.
    Thanks,
    Prathyusha.

  • How to find child records is exists before to delete parent records.

    Dear Everyone,
    I would like to ask you, is there any simple way to find child records is exists before to delete parent records.
    I have a master table defined primary key and I have referenced that as foreign key in many tables.
    I have used Delete_Record to delete but it isn't display the message 'child record exist' but it cleared the record from the form. So I need to know how to find child records is exists or not before to do delete_record so that I can display message in-case it exists.
    I do know we can able to check in every table matching the column manually, but what if we use 100 of tables then it is not possible to check manually.
    I am sure there must be simple way to find as how the oracle identifies when we execute delete query.
    Please help me on this.
    Thanks in advance.

    Simple solution is to run the query I have given for all child tables or to try a single query for all child tables withj something like:
    select <parent_key>
    from <parent_table>
    where <parent_key> in
              (select <foreign_key_1> from <child_table_1> union
               select <foreign_key_2> from <child_table_2> union
               ... );More complicate solution could be to change the foreign key constraints to cascade DELETE on parent table to child tables:
    SQL>
    SQL> create table p(x int primary key);
    Table created.
    SQL> create table c1(x1 int);
    Table created.
    SQL> create table c2(x2 int);
    Table created.
    SQL>
    SQL> alter table c1 add constraint fk1 foreign key(x1) references p;
    Table altered.
    SQL> alter table c2 add constraint fk2 foreign key (x2) references p;
    Table altered.
    SQL>
    SQL>
    SQL> insert into p values(1);
    1 row created.
    SQL> insert into c1 values(1);
    1 row created.
    SQL> insert into c2 values(1);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL>
    SQL> alter table c1 drop constraint fk1;
    Table altered.
    SQL> alter table c2 drop constraint fk2;
    Table altered.
    SQL>
    SQL> alter table c1 add constraint fk1 foreign key(x1) references p on delete cascade;
    Table altered.
    SQL> alter table c2 add constraint fk2 foreign key (x2) references p on delete cascade;
    Table altered.
    SQL>
    SQL> delete p where x=1;
    1 row deleted.
    SQL> commit;
    Commit complete.
    SQL> select * from p;
    no rows selected
    SQL> select * from c1;
    no rows selected
    SQL> select * from c2;
    no rows selected
    SQL>Edited by: P. Forstmann on 27 oct. 2011 14:01

  • Insert child record when user commit parent data

    Hi everybody,
    My use case is an admin users page, where users add new users to application. So they specify user_name, last_name, .....
    I'd need to insert in a child record whose FK is user_name which was introduced by user in the parent table, just in the commit stage.
    How can I achive it? I'm user Jdev 12.1.2
    Regards,
    Jose.

    well leave that example...
    How you commiting the first row.. are using commit operation.Commit in bean using java code like this.
    public static OperationBinding findOperation(String operationName) {
       OperationBinding op = getDCBindingContainer().getOperationBinding("Commit");
       if (op == null) {
          throw new RuntimeException("Operation '" + operationName +"' not found");
       return op;
    . and after this you can get instance of vo of second VO. then create row
    ViewObjectImpl demo1 = am.getEmployeesDemo1();
           Row r2 = demo1.createRow();         // Creates a row in ViewObject
           r2.setAttribute("EmployeeId", 001); // you can set all values
           demo1.insertRow(r2);                //Insert that row in ViewObject
           am.getDBTransaction().commit();     //Commit the changes
           demo1.executeQuery();

  • How to update child record when item from parent record changes

    Hi, I have a master and detail form with two regions on the same page.
    Region one references parent record, one of column in the parent record is also in the child record. And is one to many relation
    between parent record and child record. How can I have the column on the child record updated when the column of the parent record is being modified?
    For exemple; Parent record has two columns : ID and Program.
    Child record has Program, goal# and status. I have two pages established, page 27 and page 28.
    Page 27 list out all programs from parent record, by clicking on edit to a program, it braches to page 28 with program listed as editable field in region one, and mulitple records list in region two from the child record with the same program.
    The problem that I am having is once the program in region one got modified using ApplyMRU, the program in child record did not get updated with the new value and therefore those record become orphan records. I need a way to update all current child records with the new program value.
    Thanks in advance for anyone who can hlep out on this problem.
    Julie
    Edited by: JulieHP on May 24, 2012 4:57 PM

    One Idea is
    If possible create a after update database trigger on the parent table to update the relevant child record.
    Next one
    Create a PL/SQL process on the parent page with process sequence next to ApplyMRU, so when the ApplyMRU is seccessfull it goes not to your process where you can have your update statement

  • Child dialog set visible before parent dialog how to avoid this

    I m using JDialog an for some validation showing JOptionPaneDialog but parent dialog get visible after some processing that depands on some thread execution so before parent dialog get visible the JOptionPaneDialog get visible how to resolve this problem

    I m using JDialog an for some validation showing JOptionPaneDialog but parent dialog get visible after some processing that depands on some thread execution so before parent dialog get visible the JOptionPaneDialog get visible how to resolve this problem

  • Duplicate records getting inserted instead of update.

    I have any entity which has multiple childern. All have one to many relation with the parent. When I update the no of childerns and merge using EntityManager. It is updating the parent and insert all the childern records, which is creating duplicates. What could be the possible error.

    Where did you read the parent object and children from originally (was it serialized?), and how are you merging it? How have you defined your id in your child objects? What version of TopLink are you using?
    Perhaps include some sample code. It most likely has something to do with how you are merging the objects, if you just read the parent and access the children, are they inserted?
    -- James : http://www.eclipselink.org

  • Two records getting inserted with the same timestamp...

              hi all,
              I am trying to submit a form . Now whenever I click submit before I insert any
              data sent in that form I make a check (SELECT stmt. to see if that record can
              be inserted ...few business validations..) and if the check is successful I then
              proceed for the necessary insert into a table the Primary key for which is a running
              Oracle sequence.
              But if I click on the Submit button twice in close succession I have observed
              may be 1 in 1000 attempts I am able to submit two records with the same time stamp
              for the date of insertion . We are using Oracle 8 with weblogic 5.1. And I don't
              think ORACLE's date precision is beyond seconds.
              So any suggestion ..what is the best way to handle such things : one can be
              to place the same business validation check just before the ending brace of the
              method , or secondly sucmit the form thru javascript and don't submit it twice
              even if the user clicks the submit button twice... any suggestion which u can
              give .. are welcome.
              thnx in advance
              sajan
              

    Is the pkey a timestamp or an Oracle sequence? The latter will always work,
              since no two requests to a sequence can get the same value (rollover
              excluded). If you must use timestamp, then you must auto-retry the insert
              if the first attempt fails. Oracle does have higher precision than seconds,
              but I can remember the exact precision ... I am pretty sure it works out to
              at least two or three digits though.
              Peace,
              Cameron Purdy
              Tangosol, Inc.
              http://www.tangosol.com
              Tangosol Server: Enabling enterprise application customization
              "Sajan Parihar" <[email protected]> wrote in message
              news:[email protected]...
              >
              > hi all,
              > I am trying to submit a form . Now whenever I click submit before I
              insert any
              > data sent in that form I make a check (SELECT stmt. to see if that record
              can
              > be inserted ...few business validations..) and if the check is successful
              I then
              > proceed for the necessary insert into a table the Primary key for which is
              a running
              > Oracle sequence.
              > But if I click on the Submit button twice in close succession I have
              observed
              > may be 1 in 1000 attempts I am able to submit two records with the same
              time stamp
              > for the date of insertion . We are using Oracle 8 with weblogic 5.1. And I
              don't
              > think ORACLE's date precision is beyond seconds.
              > So any suggestion ..what is the best way to handle such things : one
              can be
              > to place the same business validation check just before the ending brace
              of the
              > method , or secondly sucmit the form thru javascript and don't submit it
              twice
              > even if the user clicks the submit button twice... any suggestion which u
              can
              > give .. are welcome.
              >
              > thnx in advance
              > sajan
              

  • ADF: controlling the order in which VO records are inserted

    All,
    in an ADF BC project, we have some complex MD insert pages that add records to master and detail tables at the same time. The application sits on top of CDM RuleFrame, which exposes the datamodel as DB views with instead-of triggers and adds (Designer) a few nifty things like auto-populated PK fields. Sad enough, we can't use these auto-generated PKs as the 'refresh after insert' settings in an EO work with a RETURNING clause, which is not supported for instead-of triggers. This means we'll have to find the PK sequences ourselves from the EOs and populate these fields ourselves, before committing to the database. So far so good, but things go wrong when we want to insert master and detail at the same time. The PK and FK of the child record are already filled in at insert time (which is nice) but for some reason the child records get inserted before the parents, resulting in an error on the FK as the parent record does not yet exist (which is not nice).
    So, here's the question: is there a way to control the order in which new VO records are inserted ? On what is the default order based (maybe a little renaming could help us out to get the alphabet our way) ?
    We know defining the FKs as 'initially deferred' will make sure they are only checked at commit time, but our DBA prefers to not use that solution unless strictly necessary. (is there anything bad about deferred keys why we should believe him? ;o) )
    And additionally, is there a way around all this manual PK-fetching ? We've tried using the refresh(int refreshMode) method of EntityImpl, but it didn't seem to work.
    Many thanks in advance for your tips, suggestions and solutiosn !
    Best regards,
    Benjamin De Boe

    Benjamin,
    To handle the problem with the child/parent records being inserted in the wrong order - have a read of the Oracle ADF Developer's Guide for Forms/4GL developers, section 26.7. I use that technique with great success.
    John

  • Cdc- deletion of parent- child records

    Hi,
    I am working with CDC-consistent feature in odi.
    Here my scenario is, I have a record say 120 (primary key) in table A(parent source table) and it is used as a foreign key in Table B.
    both child and parent are inserted into the concerned tables of target.
    Now i want to delete this 120 record from target parent and child tables.
    IN the pkg i arranged the pkg scenarios as follows
    odiwaitforlogdata----->source model(with extenwindow and lock subscriber option selected)------>parent pkg scenario------>child pkg scenario----->source mode(with unlock subscriber and purge journal options). ------------> This works fine for insert and update.
    odiwaitforlogdata----->source model(with extenwindow and lock subscriber option selected)------>child pkg scenario--------->parent pkg scenario----->source mode(with unlock subscriber and purge journal options). ------------> This works fine for delete.
    Can't I achieve these two in one pkg
    Please Guide.
    Regards,
    Chaitanya.

    Hi,
    kev374 wrote:
    Thanks, one question...
    I did a test and it seems the child rows have to also satisfy the parent row's where clause, take this example:
    EVENT_ID|PARENT_EVENT_ID|CREATED_DATE
    2438 | (null) | April 9 2013
    2439 | 2438 | April 11 2013
    2440 | 2438 | April 11 2013
    select * from EVENTS where CREATED_DATE < sysdate - 9
    start with EVENT_ID = 2438
    connect by PARENT_EVENT_ID = prior EVENT_IDSo you've changed the condition about only wanting roots and their children, and now you want descendants at all levels.
    This pulls in record #2438 (per the sysdate - 9 condition) but 2439 and 2440 are not connected. Is there a way to supress the where clause evaluation for the child records? I just want to pull ALL child records associated with the parent and only want to do the date check on the parent.Since the roots (the only rows you want to exclude) have LEVEL=1, you can get the results you requested like this:
    WHERE   created_date  < SYSDATE - 9
    OR      LEVEL         > 1However, since you're not ruling out the grandchildren and great-grandchildren any more, why wouldn't you just say:
    SELECT  *
    FROM    events
    WHERE   created_date     < SYSDATE - 9
    OR      parent_event_id  IS NOT NULL;?
    CONNECT BY is slow. Don't use it if you don't need it.
    If you x-reference my original query:
    select * from EVENTS where CREATED_DATE < sysdate - 90 and PARENT_EVENT_ID is null -- All parents
    union
    select * from EVENTS where PARENT_EVENT_ID in (select EVENT_ID from EVENTS where CREATED_DATE < sysdate - 90 and PARENT_EVENT_ID is null) -- include any children of parents selected from above
    The 2nd select does not apply the created_date < sysdate - 90 on the children but rather pulls in all related children :)Sorry; my mistake. That's what happens when you don't post sample data, and desired results; people can't test their solutions and find mistakes like that.

  • ADF,how to delete parent record and related child record without manual cod

    Hi All,
    I'm using 11g adf.
    I have one parent table PAR and two child table CHD1 , CHD2 respectively.
    I'm inserting values in three tables , making a form having add , delete and edit buttons.
    Issue when i want to delete a record from PAR table , it gives child table record exists . i have did manual coding to delete the child records with related to the selected parent table PAR.
    Is there any process in ADF to delete the child records with respective selected parent record with out manual coding.
    thanks in advance.

    http://download.oracle.com/docs/cd/E14571_01/web.1111/b31974/bcentities.htm#BABHFJFJ
    John

  • Parent/child records from same table

    I want to create a query that is a union such that the 2nd resultset is based on the 1st resultset. I have a table that has parent/child records in the same table.
    Table: EVENTS
    EVENT_ID
    PARENT_EVENT_ID
    CREATED_DATE
    (other columns)
    if PARENT_EVENT_ID is null then it is a parent record, else it is a child record. I want to select all parent records then union them with all the associated child records...something like this:
    select * from EVENTS where CREATED_DATE < sysdate - 90 and PARENT_EVENT_ID is null -- All parents
    union
    select * from EVENTS where PARENT_EVENT_ID in (select EVENT_ID from EVENTS where CREATED_DATE < sysdate - 90 and PARENT_EVENT_ID is null) -- include any children of parents selected from above
    This works but it's kind of ugly, I want to avoid using the sub-select in the 2nd because it is a repeat of the 1st statement, is there a way to alias the first statement and just refer to it in the 2nd query?

    Hi,
    kev374 wrote:
    Thanks, one question...
    I did a test and it seems the child rows have to also satisfy the parent row's where clause, take this example:
    EVENT_ID|PARENT_EVENT_ID|CREATED_DATE
    2438 | (null) | April 9 2013
    2439 | 2438 | April 11 2013
    2440 | 2438 | April 11 2013
    select * from EVENTS where CREATED_DATE < sysdate - 9
    start with EVENT_ID = 2438
    connect by PARENT_EVENT_ID = prior EVENT_IDSo you've changed the condition about only wanting roots and their children, and now you want descendants at all levels.
    This pulls in record #2438 (per the sysdate - 9 condition) but 2439 and 2440 are not connected. Is there a way to supress the where clause evaluation for the child records? I just want to pull ALL child records associated with the parent and only want to do the date check on the parent.Since the roots (the only rows you want to exclude) have LEVEL=1, you can get the results you requested like this:
    WHERE   created_date  < SYSDATE - 9
    OR      LEVEL         > 1However, since you're not ruling out the grandchildren and great-grandchildren any more, why wouldn't you just say:
    SELECT  *
    FROM    events
    WHERE   created_date     < SYSDATE - 9
    OR      parent_event_id  IS NOT NULL;?
    CONNECT BY is slow. Don't use it if you don't need it.
    If you x-reference my original query:
    select * from EVENTS where CREATED_DATE < sysdate - 90 and PARENT_EVENT_ID is null -- All parents
    union
    select * from EVENTS where PARENT_EVENT_ID in (select EVENT_ID from EVENTS where CREATED_DATE < sysdate - 90 and PARENT_EVENT_ID is null) -- include any children of parents selected from above
    The 2nd select does not apply the created_date < sysdate - 90 on the children but rather pulls in all related children :)Sorry; my mistake. That's what happens when you don't post sample data, and desired results; people can't test their solutions and find mistakes like that.

  • If Records of different list items are entered, then the data is not getting inserted in the table.

    Hi Everyone,
    A Very Very Happy, Fun-filled, Awesome New Year to You All.
    Now coming to the discussion of my problem in Oracle Forms 6i:
    I have created a form in which the data is entered & saved in the database.
    CREATE TABLE MATURED_FD_DTL
      ACCT_FD_NO    VARCHAR2(17 BYTE)               NOT NULL,
      CUST_CODE     NUMBER(9),
      FD_AMT        NUMBER(15),
      FD_INT_BAL    NUMBER(15),
      TDS           NUMBER(15),
      CHQ_NO        NUMBER(10),
      CREATED_DATE  DATE,
      CREATED_BY    VARCHAR2(15 BYTE),
      PREV_YR_TDS   NUMBER(15),
      ADD_FD_AMT    NUMBER(15),
      DESCRIPTION   VARCHAR2(100 BYTE),
      P_SAP_CODE    NUMBER(10),
      P_TYPE        VARCHAR2(1 BYTE)
    The form looks like below:
    ENTER_QUERY     EXECUTE_QUERY     SAVE     CLEAR     EXIT
    ACCT_FD_NO
    CUST_CODE
    FD_AMT
    FD_INT_BAL
    PREV_YR_TDS
    TDS
    ADD_FD_AMT
    P_SAP_CODE
    P_TYPE
    CHQ_NO
    DESCRIPTION
    R
    W
    P
    List Item
    There are 5 push buttons namely ENTER_QUERY, EXECUTE_QUERY, SAVE, CLEAR, EXIT.
    The table above is same as in the form. All the fields are text_item, except the P_TYPE which is a List_Item ( Elements in List Item are R, W & P).
    The user will enter the data & save it.
    So all this will get updated in the table MATURED_FD_DTL .
    I am updating one column in another table named as KEC_FDACCT_MSTR.
    and
    I want this details to get updated in another table named as KEC_FDACCT_DTL only if the P_TYPE='P'
    CREATE TABLE KEC_FDACCT_DTL
      FD_SR_NO                NUMBER(8)             NOT NULL,
      FD_DTL_SL_NO            NUMBER(5),
      ACCT_FD_NO              VARCHAR2(17 BYTE)     NOT NULL,
      FD_AMT                  NUMBER(15,2),
      INT_RATE                NUMBER(15,2),
      SAP_GLCODE              NUMBER(10),
      CATOGY_NAME             VARCHAR2(30 BYTE),
      PROCESS_YR_MON          NUMBER(6),
      INT_AMT                 NUMBER(16,2),
      QUTERLY_FD_AMT          NUMBER(16,2),
      ITAX                    NUMBER(9,2),
      MATURITY_DT             DATE,
      FDR_STAUS               VARCHAR2(2 BYTE),
      PAY_ACC_CODE            VARCHAR2(85 BYTE),
      BANK_CODE               VARCHAR2(150 BYTE),
      NET_AMOUNT_PAYABLE      NUMBER,
      QUATERLY_PAY_DT         DATE,
      CHEQUE_ON               VARCHAR2(150 BYTE),
      CHEQUE_NUMBER           VARCHAR2(10 BYTE),
      CHEQUE_DATE             DATE,
      MICR_NUMBER             VARCHAR2(10 BYTE),
      PAY_TYPE                VARCHAR2(3 BYTE),
      ADD_INT_AMT             NUMBER(16,2),
      ADD_QUTERLY_FD_AMT      NUMBER(16,2),
      ADD_ITAX                NUMBER(16,2),
      ECS_ADD_INT_AMT         NUMBER(16),
      ECS_ADD_QUTERLY_FD_AMT  NUMBER(16),
      ECS_ADD_ITAX            NUMBER(16)
    So for the push button 'Save' , i have put in the following code in the Trigger : WHEN BUTTON PRESSED,
    BEGIN
         Commit_form;
              UPDATE KEC_FDACCT_MSTR SET PAY_STATUS='P' WHERE ACCT_FD_NO IN (SELECT ACCT_FD_NO FROM MATURED_FD_DTL);
              UPDATE MATURED_FD_DTL SET CREATED_DATE=sysdate, CREATED_BY = :GLOBAL.USER_ID WHERE ACCT_FD_NO = :acct_fd_NO;
    IF :P_TYPE='P' THEN
         INSERT INTO KEC_FDACCT_DTL
              SELECT FD_SR_NO, NULL, MATURED_FD_DTL.ACCT_FD_NO, FD_AMT, INT_RATE, P_SAP_CODE,
                   GROUP_TYPE, (TO_CHAR(SYSDATE, 'YYYYMM'))PROCESS_YR_MON,
                   FD_INT_BAL, (FD_INT_BAL-MATURED_FD_DTL.TDS)QUTERLY_FD_AMT , MATURED_FD_DTL.TDS,
                   MATURITY_DATE, P_TYPE, NULL, NULL, (FD_INT_BAL-MATURED_FD_DTL.TDS)NET_AMOUNT_PAYABLE,
                   NULL, NULL, CHQ_NO, SYSDATE, NULL, 'CHQ', NULL, NULL, NULL, NULL, NULL, NULL
              FROM MATURED_FD_DTL, KEC_FDACCT_MSTR
         WHERE KEC_FDACCT_MSTR.ACCT_FD_NO=MATURED_FD_DTL.ACCT_FD_NO;
    END IF;
    COMMIT;
         MESSAGE('RECORD HAS BEEN UPDATED AS PAID');
         MESSAGE(' ',no_acknowledge);
    END;
    If P_TYPE='P' , then the data must get saved in KEC_FDACCT_DTL table.
    The problem what is happening is,
    If i enter the details with all the records as 'P' , the record gets inserted into the table KEC_FDACCT_DTL
    If i enter the details with records of 'P' and 'R' , then nothing gets inserted into the table KEC_FDACCT_DTL.
    Even the records with 'P' is not getting updated.
    I want the records of 'P' , to be inserted into table KEC_FDACCT_DTL, even when multiple records of all types of 'P_Type' (R, w & P) are entered.
    So, can you please help me with this.
    Thank You.
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    Oracle Forms Builder 6i.

    Its not working properly.
    At Form_level_Trigger: POST_INSERT, I have put in the following code.
    IF :P_TYPE='P'THEN
      INSERT INTO KEC_FDACCT_DTL
      SELECT FD_SR_NO, NULL, MATURED_FD_DTL.ACCT_FD_NO, FD_AMT, INT_RATE, P_SAP_CODE,
      GROUP_TYPE, (TO_CHAR(SYSDATE, 'YYYYMM'))PROCESS_YR_MON,
      FD_INT_BAL, (FD_INT_BAL-MATURED_FD_DTL.TDS)QUTERLY_FD_AMT , MATURED_FD_DTL.TDS,
      MATURITY_DATE, P_TYPE, NULL, NULL, (FD_INT_BAL-MATURED_FD_DTL.TDS)NET_AMOUNT_PAYABLE,
      NULL, NULL, CHQ_NO, SYSDATE, NULL, 'CHQ', NULL, NULL, NULL, NULL, NULL, NULL
      FROM MATURED_FD_DTL, KEC_FDACCT_MSTR
      WHERE KEC_FDACCT_MSTR.ACCT_FD_NO=MATURED_FD_DTL.ACCT_FD_NO;
      END IF;
    MESSAGE('RECORD HAS BEEN UPDATED AS PAID');
    MESSAGE(' ',no_acknowledge);
    It worked properly when i executed first time, but second time , in database duplicate values were stored.
    Example: First I entered the following in the form & saved it.
    ACCT_FD_NO
    CUST_CODE
    FD_AMT
    FD_INT_BAL
    PREV_YR_TDS
    TDS
    ADD_FD_AMT
    P_SAP_CODE
    P_TYPE
    CHQ_NO
    DESCRIPTION
    250398
    52
    50000
    6000
    0
    600
    0
    45415
    P
    5678
    int1
    320107
    56
    100000
    22478
    3456
    2247
    0
    45215
    R
    456
    320108
    87
    50000
    6500
    0
    650
    0
    21545
    W
    0
    In the database, in table KEC_FDACCT_DTL, the ACCT_FD_NO:250398 with P_TYPE='P' record was inserted.
    ACCT_FD_NO
    P_TYPE
    250398
    P
    But second time, when i entered the following in the form & saved.
    ACCT_FD_NO
    CUST_CODE
    FD_AMT
    FD_INT_BAL
    PREV_YR_TDS
    TDS
    ADD_FD_AMT
    P_SAP_CODE
    P_TYPE
    CHQ_NO
    DESCRIPTION
    260189
    82
    50000
    6000
    0
    600
    0
    45415
    P
    5678
    interest567
    120011
    46
    200000
    44478
    0
    4447
    0
    45215
    R
    456
    30191
    86
    50000
    6500
    0
    650
    0
    21545
    W
    56
    In the database, in the table KEC_FDACCT_DTL, the following rows were inserted.
    ACCT_FD_NO
    P_TYPE
    250398
    P
    250398
    P
    260189
    P
    320107
    R
    320108
    W
    There was duplicate of 250398 which i dint enter in the form second time,
    All the other P_TYPE was also inserted , but i want only the P_TYPE='P' to be inserted into the database.
    I want only those records to be inserted into the form where P_TYPE='P' and duplicate rows must not be entered.
    How do i do this???

  • Finding the complete hierarchy of all child records for a given root

    Hi,
    We need to find the hierarchy starting from a given root by exploding the hierarchy of each child present in the hierarchy.
    Consider a data as given below.
    Seq_no denotes a primary key.
    Child_id denotes the child node in the hierarchy
    Parent_id indicates the immediate parent of the child record
    Root_id denotes the starting point of the hierarchy.
    Within a given hierarchy the root_id will remain the same and parent_id will keep on changing as required.
    Seq_No Child_id     Parent_id     Root_id
    101          1          NULL     1
    102          2          1          1
    103          3          2          1
    104          4          1          1
    105          5          3          1
    106 4 NULL 4
    107 7 4 4
    108 8 4 4
    109 9 7 4
    110 3 NULL 3
    111 4 3 3
    112 5 3 3
    The requirement is to pull the hierarchy starting from a given root traversing down the path by exploding the hierarchy of each and every child present in that hierarchy. It is explained using below example.
    For root_id value as 4, the expected o/p is
    child_id path
    7 /7
    9 /7/9
    8 /8
    For root_id value as 3, the expected o/p is
    child_id path
    4 /4
    7 /4/7 ---> Hierarchy with root_id 4 gets exploded
    8 /4/8
    9 /4/7/9
    5 /5
    For root_id value as 1, the expected o/p is
    child_id path
    2 /2
    3 /2/3 ---> Hierarchy with root_id 3 gets exploded
    4 /2/3/4 ---> Hierarchy with root_id 4 gets exploded
    7 /2/3/4/7
    9 /2/3/4/7/9
    8 /2/3/4/8
    5 /2/3/5
    4 /4
    7 /4/7
    8 /4/8
    9 /4/7/9
    5 /5
    5 /2/3/5
    Also, additionally, if there exist any cyclic child records in the hierarchy, the exploding should stop there itself.
    CREATE TABLE xyz
    SEQ_NO NUMBER,
    ITEM_ID NUMBER,
    PARENT_ITEM_ID NUMBER,
    ROOT_ITEM_ID NUMBER
    Insert into xyz
    (SEQ_NO, ITEM_ID, ROOT_ITEM_ID)
    Values
    (1, 1, 1);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (2, 2, 1, 1);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (3, 3, 1, 1);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (4, 4, 2, 1);
    Insert into xyz
    (SEQ_NO, ITEM_ID, ROOT_ITEM_ID)
    Values
    (8, 3, 3);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (9, 10, 3, 3);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (10, 11, 10, 3);
    Insert into xyz
    (SEQ_NO, ITEM_ID, ROOT_ITEM_ID)
    Values
    (12, 10, 10);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (13, 12, 10, 10);
    Insert into xyz
    (SEQ_NO, ITEM_ID, ROOT_ITEM_ID)
    Values
    (14, 11, 11);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (15, 13, 11, 11);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (16, 14, 11, 11);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (21, 23, 13, 11);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (104, 16, 91, 14);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (19, 16, 12, 10);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (20, 17, 16, 10);
    Insert into xyz
    (SEQ_NO, ITEM_ID, ROOT_ITEM_ID)
    Values
    (101, 110, 110);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (102, 111, 110, 110);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (103, 17, 110, 110);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (29, 31, 17, 10);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (30, 32, 17, 10);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (31, 33, 16, 10);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (35, 49, 23, 11);
    Insert into xyz
    (SEQ_NO, ITEM_ID, ROOT_ITEM_ID)
    Values
    (41, 14, 14);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (42, 91, 14, 14);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (43, 92, 91, 14);
    COMMIT;
    Pl advise.
    Thanks,
    - Ajit
    Edited by: 952105 on Aug 10, 2012 10:44 AM

    My application tracks the product master that stores a product configuration along with its all child/sub-child records. There exists many such configurations for various parts.
    There can exist only one configuration for a given product at any point in time. But, at the same time, this product can be a part of other product configurations too (i.e. it can exist as a child in other hierarchies).
    Now, the business requirement is to pull the hierachy starting from a given product (as a root). This should also pull the hierarchy of each child/subchild existing under its hieararchy, if there exist a separate configuration for those child/subchild products.
    SET DEFINE OFF;
    CREATE TABLE XYZ
    ITEM_ID NUMBER,
    PARENT_ITEM_ID NUMBER,
    ROOT_ITEM_ID NUMBER,
    QUANTITY NUMBER,
    LINE_ID VARCHAR2(10 BYTE)
    Here, root_item_id denotes the product for which the configuration has been defined. All its child/sub-child records gets stored under this root_item_id itself. The parent_item_id column will get stored appropriately based on the immediate parent of the product under that hierarchy.
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (2, 1, 1, 5, '1.1');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (3, 1, 1, 5, '1.2');
    Insert into XYZ
    (ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (1, 1, 1, '1.0');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (4, 2, 1, 6, '1.1.1');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (10, 3, 3, 4, '1.1');
    Insert into XYZ
    (ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (3, 3, 4, '1.0');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (11, 10, 3, 15, '1.1.1');
    Insert into XYZ
    (ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (10, 10, 7, '1.0');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (12, 10, 10, 9, '1.1');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (16, 12, 10, 99, '1.1.1');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (17, 16, 10, 77, '1.1.1.1');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (31, 17, 10, 2, '1.1.1.1.1');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (33, 16, 10, 5, '1.1.1.2');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (32, 17, 10, 3, '1.1.1.1.2');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (14, 11, 11, 10, '1.2');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (13, 11, 11, 9, '1.1');
    Insert into XYZ
    (ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (11, 11, 8, '1.0');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (23, 13, 11, 77, '1.1.1');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (49, 23, 11, 5, '1.1.1.1');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (16, 91, 14, 56, '1.1.2');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (92, 91, 14, 10, '1.1.1');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (91, 14, 14, 8, '1.1');
    Insert into XYZ
    (ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (14, 14, 6, '1.0');
    Insert into XYZ
    (ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (110, 110, 1, '1.0');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (17, 110, 110, 1, '1.2');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (111, 110, 110, 1, '1.1');
    COMMIT;
    The expected result for product with root_item_id as 14
    item_id hierarchy_path
    11 /11
    13 /11/13
    23 /11/13/23
    49 /11/13/23/49
    14 /11/14 -- it should explode the hierarchy of product with id 14
    91 /11/14/91 as there exists a configuration for this product as a root
    16 /11/14/91/16
    92 /11/14/91/92
    In above example, it should explode the hierarachy of other products too (item_id 13,23 etc) if there exists a product configuration (starting with root_item_id as 13 or 23 etc.) for them in the table.
    Thanks,
    - Ajit

  • Problem of orphan child records

    Hi
    I am working on Oracle 8i DB. The production database contians around 100 tables.About 60% tables are interrelated by referential integrity . However , there are some records found which are not such that child records are present without parent records .These occurs when some procedure handles some exception .
    Can I right some user procedure which can scan the schema and found child records which are orphan and user can be tld to correct ones.
    Prashant

    yes of course.
    Example:
    I have a table t_consumer with emp_id and location as pk with other fields.
    I haev one more table t_locations with location as pk.
    The tables are related that emp_id table location must be present in t_locations.
    However due to some constraints disablement during some ddl , some records in t_emp table are having location which does not exists in table t_location.
    There are about 100 tables in product DB with around 40000 records in each. I have to find records with such mismatch.
    Prashant

Maybe you are looking for

  • Merged overlay not saving to AVI

    LV2013/Vision 2013 In a loop, I am grabbing images from a camera using the Vision Acquisition express vi.  To the output image, I add a text overlay of the system time (e.g., 11:23:56.489).  The overlay is pure white text on a pure black background.

  • Adobe Acrobat 9 pro and windows 7

    I have Adobe acrobat 9 pro and installed it on my Dell windows 7 desktop.  When I go to print to Adobe the pictures come up in the print screen with a green hue or tint to them. To view the pictures in the folder they are fine. To actually print the

  • I can't get video to export into my pdf

    I can import a video which plays fine in Acrobat Pro but when I go to save it as a pdf the video disapears in the pdf document. But, all other text related changes come through as expected. I've tried flv's and h.264's with no luck from either. I'm o

  • External Apple isight with a imac G5

    Really need help to figure this one out. I have not used this isight before it has been bought secondhand. Trying to use an external Apple isight with a imac G5 (without built in isight) running on Leopard OSX 10.5.8. looked in my Utilities and can't

  • How i can reach to my PDF files in my computer's desktop from my Adob Acount ?

    how i can reach to my PDF files in my computer's desktop from my Adob Acount ?