How to filter parent and child tables data in impdp?

Hi Friends,
i hope everyone doing good..
I have two tables in my schema like below.
STUDENT_DTLS:-
SID Sname CID
1     venkat     001
2     uppy     002
3     deepu     003
4     trinath     003
5     naveen     004
6     ramesh     005
COURSE_DTLS:-
CID CNAME Fee
001     Oracle     2000
002     java     6000
003     sieble     4000
004     informatica     3000
005     obiee 4000
if I load only few Student details say sid=1,2,3 into another environment using impdp,corresponding to those students course details from COURSE_DTLS table only need to be loaded.Not all course details.
Iam Expecting Result in new schema as below:-
SID Sname CID
1     venkat     001
2     uppy     002
3     deepu     003
CID CNAME Fee
001     Oracle     2000
002     java     6000
003     sieble     4000
But when i am using the below import scrit,The COURSE_DTLS is loading first and its query option(select cid from STUDENT_DTLS) is returning no rows.Because at that time no data is insertred into STUDENT_DTLS yet.
secondly it is importing data into STUDENT_DTLS with query option where sid=in (1,2,3) which is loaded propelry.
Thirdly it is trying to enable primary key and Foreign key constraints which is also failing because of no data in COURSE_DTLS table.
i have changed the order of tables in TABLES clause like tables=COURSE_DTLS ,STUDENT_DTLS.But still COURSE_DTLS table is loading first.
impdp pa_data_sub/******* NETWORK_LINK=qdssih30 tables=STUDENT_DTLS,COURSE_DTLS query='STUDENT_DTLS:"where SID IN(1,2,3)"','COURSE_DTLS:"where cid in(select cid from STUDENT_DTLS)"', CONTENT=all table_exists_action=replace directory=DATA_PUMP_DIR logfile=exp_join.log
output:
Total estimation using BLOCKS method: 128 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
. . imported "PA_DATA_SUB"."COURSE_DTLS" 0 rows
. . imported "PA_DATA_SUB"."STUDENT_DTLS" 3 rows
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
ORA-39083: Object type REF_CONSTRAINT failed to create with error:
ORA-02298: cannot validate (PA_DATA_SUB.SYS_C0040905) - parent keys not found
Failing sql is:
ALTER TABLE "PA_DATA_SUB"."STUDENT_DTLS" ADD FOREIGN KEY ("CID") REFERENCES "PA_DATA_SUB"."COURSE_DTLS" ("CID") ENABLE
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "PA_DATA_SUB"."SYS_IMPORT_TABLE_01" completed with 1 error(s) at 17:28:13
Please suggest me how to achieve this task in a single import command?
Is there any option in impdp to prioritize the table to be loaded first?
Thanks,
Venkat Vadlamudi

You can't be guaranteed which order the data will be loaded in, so using a query that examines a table that is being imported is not going to always work the way you want it. The failing constraints makes sense because there is no data.
So, in your case, course_dtls gets imported first and the table student-dtls exists, but it not populated yet, so the select cid from student_dtls comes back with 0 rows. The second query works fine.
You might be able to change the query to be:
'COURSE_DTLS:"where cid in(select cid from STUDENT_DTLS@qdssih30 where SID IN(1,2,3)"'
This way, you query the source table pointed to by the network link and you use the same subquery from the first table.
This should work for you... I think anyway.
Dean

Similar Messages

  • How to update parent and child tables while updating parent table

    I have a parent table EMPLOYEE which includes columns (sysid, serviceno,employeename...) sysid is Primary key, serviceno is Unique key and I have child table DEPENDENT includes columns (sysid,employee_sysid,name,dob...) here again SYSID is primary key for DEPENDENTS table, employee_sysid is Foreign key of EMPLOYEE table.
    Now I want to change SYSID (using sequence) in EMPLOYEE table which need to be update in DEPENDENTS table as well
    Note: I have 10000 records in EMPLOYEE table as well as I have 5 more child tables which need to update new SYSID.
    please help me

    first disable the FOREIGN KEY Constraints.
    you can update Parent as well as Child record also with help of trigger.
    here i am giving you one examlpe..it may help u.
    create table parent(id number primary key,name varchar2(100))
    create table child_1(id number primary key,p_id number,dob date,
    CONSTRAINT FK_id FOREIGN KEY (p_id) REFERENCES parent (ID))
    create table child_2(id number primary key,p_id2 number,addr varchar2(1000),
    CONSTRAINT FK_id2 FOREIGN KEY (p_id2) REFERENCES parent (ID))
    insert some test data to parent and child tables.
    alter table child_2 disable constraint FK_id2
    alter table child_1 disable constraint FK_id2
    CREATE OR REPLACE TRIGGER delete_child
    BEFORE UPDATE ON parent
    FOR EACH ROW
    BEGIN
    UPDATE CHILD_1
    SET P_ID=:NEW.ID
    WHERE P_ID=:OLD.ID;
    UPDATE CHILD_2
    SET P_ID2 =:NEW.ID
    WHERE P_ID2=:OLD.ID;
    END;
    then Upadte parent table primary key col and check the child tables.
    then enable the constraints...

  • Insert data Flatfile table to Parent and child tables

    Hi All,
        I have Flatfile table which is we getting from daily txt files and i want to populate flatfile data to parent as well as child tables. parent table has primary key as ID. This ID is foreign key of child tables. 
    Here i have mentioned our process.
    1. Flatfile duplicates has to remove with condition of daily date.
    2. Before Insert parent table have to check duplicate(we have Unique key of 4 columns in parent) if duplicate is there we have to delete duplicate then Insert into parent table unique records(Primary key is ID).(here why we are delete duplicate record meaning
    we getting daily files so if any records updated in future that record should be insert to parent and child table so only we delete old records and insert new records).
    3.After insert parent we have to populate child tables from Flatfile table as well as we have to insert parent table primary key as foreign key of child tables.
    4. if any truncation error occurs that errors should go to error log table.
    Right now we are using cursor for this concept and cursor has performance issue. so we are trying to optimize other way to populate parent and child table to increase performance to populate.
    Please help us to which way to do this process increase of performance .
    Please  can any one reply.

    Hi RajVasu,
    Since this issue is related to Transact-SQL, I will move this thread to Transact-SQL forum. Sometime delay might be expected from the job transferring. Your patience is greatly appreciated. 
    Thank you for your understanding and support.
    Regards,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How to link parent and child relation in Metapedia

    How to link parent and child relation in Metapedia

    Vamsi,
    Did you every determine how to do what you were asking about? Where you thinking of how to link a parent term to a child term (i.e. like a related term) or was this about linking a term to a different metadata object (e.g. table or report) ?

  • Update column data to Upper Case in parent and child table

    Hi ,
    I am facing issue while updating column value to upper case in parent table and child table. How can i do that ?
    when updating parent row:
    ORA-02292: integrity constraint (XXXXXXXXXXXXXX_FK) violated - child record found
    When updatng corresponding child row:
    ORA-02291: integrity constraint (XXXXXXXXXXXXXXXX_FK) violated - parent key not found
    how can i update on both the places ?
    Regards,
    AA

    I am facing issue while updating column value to upper case in parent table and child table. How can i do that ?
    Why do you need to do that?
    That is just ONE of several questions you should answer before you start modifying your data.
    1. What is your 4 digit Oracle version? (result of SELECT * FROM V$VERSION)
    2. If both values are the same case what difference does it make what that case is?hen you don't need to alter your original data.
    3. What is the source of the column values you are using now? If you change your data to upper case it will no longer be identical to the source data.
    4. What is your plan for enforcing future values to be stored in UPPER case? Are you going to use a trigger? Have you written and tested such a trigger to see if it will even work the way you expect?
    5. Why aren't you using a surrogate key instead of a 'business' data item? You have just demonstrated one reason why surrogate keys can be useful: their actual value is NOT important.
    You should reexamine your problem and architecture and consider other alternatives.
    One alternative is to add a new 'surrogate key' column to use as the primary key. Just create a new sequence and use a trigger to populate the new column. Your current plans will require a trigger to perform the case conversion so instead of the just use the trigger to provide the value.
    If the change is being done to facilitate searching you could just add a VIRTUAL column UPPER_MY_COLUMN and index that instead. Then you could search on that new virtual column and the data values would still be identical to the original data source.

  • How to persist parent  and child tree node data through JSF and Hibernate

    Dear dudes,
    I'm a novice to JSF and Hibernate
    Actually i want to create a tree structure where for each child node, i should have the parent node reference in my form and then when i save, i need to save the corresponding child node data in the database.
    node-1
      node 1-1
         node 1-11a
      node 1-2
    node-2
       node 2-1
       node2-2Whenever i click node 1-1 the corresponding parent node ( node-1) reference should appear in my form and when i save this data this data should be saved under parent node and the tree should be re-rendered.
    How this can be accomplished and if there are any URL's please refer.

    Everybody need not face the same problem you faced. And moreover, everyone out here have their own issues to solve. If people are helping out here, its cause of their passion. Please try to be polite.
    First of all, what is that you have tried on the issue? Could you please share your work so that we can try to fill the gaps?

  • DB Adapter wizard – WHERE clause on parent and child tables not working.

    I have two tables, SECURITY and SECURITY_POSITIONS, where SECURITY has a 1:M relationship with SECURITY_POSITIONS. I used the DB-adapter wizard to create the relationship and the following WHERE clause expression which is looking at both the parent and the child tables;
    The expression builder looks like this:
    AND
    |--- 1. partitionKey EQUAL p_SearchKey
    |--- 2. securityType EQUAL “DBT”
    |--- 3. securityPositionsCollection.dealReference EQUAL “NA”
    The primary key on SECURITY = PARTITION_KEY and SECURITY_REFERENCE
    The foreign key from SECURITY_POSITIONS to SECURITY = PARTITION_KEY and SECURITY_REFERENCE
    securityType is on SECURITY table (master)
    securityPositionsCollection.dealReference is on SECURITY_POSITIONS table (child)
    The invoke on the database adapter is selecting a row in securityPositionsCollection for each child row, rather than just those with dealReference = “NA”!
    I turned on DEBUG logging in the BPEL console and I can see that there are 2 SELECT queries run (guess this is how Toplink does it!), where the 1st query appears to select the parent rows and the 2nd query selects the child rows.
    However the 2nd query is not working because it is failing to select only those child rows where dealReference = “NA”. Also, don’t know why the 2nd SELECT query needs to specify the child SECURITY_POSITIONS table twice in the FROM clause, because that seems to be causing the problem.
    1st query executed is as follows;
    SELECT DISTINCT t0.PARTITION_KEY, t0.SECURITY_REFERENCE, t0.SECURITY_TYPE
    FROM CENTRAL.SECURITY t0, CENTRAL.SECURITY_POSITIONS t1
    WHERE ((((t0.PARTITION_KEY = ?) AND (t0.SECURITY_TYPE = ?)) AND (t1.DEAL_REFERENCE = ?)) AND ((t1.SECURITY_REFERENCE = t0.SECURITY_REFERENCE) AND (t1.PARTIT
    ION_KEY = t0.PARTITION_KEY)))
    bind => [200706200000, DBT, NA]
    2nd query executed is as follows, where child table appears twice! ;
    SELECT DISTINCT t0.DEAL_REFERENCE, t0.PARTITION_KEY, t0.SECURITY_REFERENCE
    FROM CENTRAL.SECURITY_POSITIONS t0,
    CENTRAL.SECURITY_POSITIONS t2,
    CENTRAL.SECURITY t1
    WHERE ((((t0.SECURITY_REFERENCE = t1.SECURITY_REFERENCE) AND (t0.PARTITION_KEY = t1.PARTITION_KEY)) AND
    (((t1.PARTITION_KEY = ?) AND (t1.SECURITY_TYPE = ?)) AND
    (t2.DEAL_REFERENCE = ?))) AND
    ((t2.SECURITY_REFERENCE = t1.SECURITY_REFERENCE) AND
    (t2.PARTITION_KEY = t1.PARTITION_KEY)))
    bind => [200706200000, DBT, NA]
    Anyone experienced the same problem e.g. why is toplink making the query more complicated that it needs to be, because the query only needs to reference the SECURITY_POSITIONS table once, as follows;
    SELECT DISTINCT t0.DEAL_REFERENCE, t0.PARTITION_KEY, t0.SECURITY_REFERENCE
    FROM CENTRAL.SECURITY_POSITIONS t0,
    CENTRAL.SECURITY t1
    WHERE ((((t0.SECURITY_REFERENCE = t1.SECURITY_REFERENCE) AND (t0.PARTITION_KEY = t1.PARTITION_KEY)) AND
    (((t1.PARTITION_KEY = '200706200000') AND (t1.SECURITY_TYPE = 'DBT')) AND
    (t0.DEAL_REFERENCE = 'NA'))) AND
    ((t0.SECURITY_REFERENCE = t1.SECURITY_REFERENCE) AND
    (t0.PARTITION_KEY = t1.PARTITION_KEY)))

    Hello,
    It looks like you have configured your 1:M relationship to use batch reading. This causes the query to bring in the Security_Position table's objects to use the same selection criteria as was used on the initial query, with a join statement. This is more efficient in most cases as it ensures only the Security_positions needed for the Security objects to be fully built are read, in a single query.
    The selection criteria added is only used to filter out the Security objects. All referenced Security_Positions must be read in for the returned Security objects so that the data matches what is in the database. If you do not want the Security_Positions, you might try using indirection on the mapping which will delay the second query until you need the Security_Positions. Or, if you want only the Security_Positions with dealReference EQUAL “NA", you could do a query specifically to filter on them.
    Best Regards,
    Chris

  • Delete entries over 1 month old in parent  and child tables

    Hi guys,
    Im new to oracle (2days old) and im struggling to find out how to delete all entries over 1 month old in a database but also delete entries from the child table. I have read about delete cascading etc but im really strugging at the moment. Any tip or ideas? thank you

    You just need to delete data in parent table using the right WHERE clause that requires some timestamp column that stores data age. If the foreign key constraint is created with ON DELETE CASCADE child rows are automatically deleted.
    Assuming P is the parent table and C the child table and the timestamp column is stored in the parent table here is an example.
    SQL> create table p(px int primary key, d date);
    Table created.
    SQL> create table  c(cx int, cy int references p on delete cascade);
    Table created.
    SQL>
    SQL> insert into p values(1, '01/01/2011');
    1 row created.
    SQL> insert into p values(2, '15/01/2011');
    1 row created.
    SQL> insert into p values(3, '31/01/2011');
    1 row created.
    SQL> insert into c values(10,1);
    1 row created.
    SQL> insert into c values(20,2);
    1 row created.
    SQL> insert into c values(30,3);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL>
    SQL> delete p where months_between(sysdate, d) >= 1;
    2 rows deleted.
    SQL>
    SQL> select * from p;
            PX D
             3 31-01-2011
    SQL> select * from c;
            CX         CY
            30          3
    SQL>Edited by: P. Forstmann on 15 févr. 2011 13:45

  • Update key in parent and child tables

    Situation:
    Parent table (p) has a PK, p.parent_id. Child table (c) has a FK c.parent_id which, of course, points back to PK, p.parent_id.
    I need to UPDATE the key in both tables but I am concerned about throwing a FK constraint violation. How does one get around this? Does one update the child first then the parent or vice versa? Seems either way a FK violation will occur...
    thank u.

    1) If you ever anticipate wanting to update a key, that key should not be the primary key of a table. Primary keys should be immutable. If this is going to happen with any regularity, you need to re-examine the underlying data model.
    2) If the constraints were declared to be deferrable, you would simply mark them as deferred, update both tables, and commit (at which point the constraint would be validated). If the constraints were not declared to be deferrable, you will probably need to end up dropping and re-creating one or the other (presumably as a deferrable constraint this time).
    Justin

  • How to delete parent and child records?

    Hi friends,
    I have a Master table and a child table.
    The Child table got reference key with the master table without on delete cascade.
    Now, I want to delete the Master records and also it's corresponding child records.
    How to do?
    Thanks in adv,
    regards,
    Vijay

    Delete the records from the child, then delete the records from the parent in two separate delete statements. I'd prefer that you create a stored procedure that does both steps.
    Justin

  • How to differentiate parent and child node in af:treeTable ?

    Greetings,
    I have a requirement, I display master child view objects using <af:treeTable> component, When user expands a parent row, I have to make parent row is in read only and expanded(child) row in editable. To accomplish this I have to identify the 'node' whether it belongs to parent or child view object. In this example Tree table binds with EmpVO, There is a view link beteween EmpVO and DepartmentVO.
    <af:treeTable value="#{bindings.EmpVO.treeModel}"
    var="node"
    rowSelection="single" id="tEqSum"
    summary="Employee Summary"
    <af:column sortProperty="#{bindings.EmpVO.hints.LocCity.name}"
    filterable="true" sortable="true" width="90"
    headerText="#{bindings.EmpVO.hints.LocCity.label}"
    id="c3">
    <af:outputText value="#{node.LocCity}" id="ot21"/>
    expandAllEnabled="false">
    </af:treeTable>
    Thanks in Advance,

    Hi,
    You can find out the node depth by using
    #{bindings.<your_tree_binding>.treeModel.depth}Based on the depth, you can decide whether its a parent node or child node (for a 1 level tree- say dept and emp, the depth for parent would be 0 and for the child it would be 1).
    -Arun

  • How to kill parent and child thread in sequnece

    Hello freinds,
    I have one class FirstClass which creates one thread Pserver and Pserver creates three threads then how to kill parent Pserver and child threads.........

    define a method that requests that the parent thread terminate itself, and within the code called when the thread is shutting itself down, have it do something similar to its child threads: call methods that request they shutdown themselves.
    One common way to do this is to interrupt the thread.

  • How to delete parent and child records together ?

    Hi,
    I'm using Jdeveloper 11.1.2.2
    I want to delete a row from a table but it is showing: Caused by: java.sql.SQLIntegrityConstraintViolationException: ORA-02292: integrity constraint (TABLE1_TL_FK1) violated - child record found.So how can I delete a Child row and table row in one method ?
    I cannot access the child's VO because it is not added to the AM.
    Thanks,
    Nigel.

    John, as usually, is right with the pointer to the documentation he pasted. Just to make sure you read it carefully, let me hoghlight an important point here:
    "If the option is selected, then the composed entities do not perform the DELETE statement *on the assumption that the database ON DELETE CASCADE constraint will handle the deletion of the corresponding rows*."
    So make sure the database is setup for cascade delete as otherwise you still will not succeed
    Frank

  • How to give filter condition in expdp to filter parent and child records?

    Hi,
    I have a requirement of export schema. Assume there is a account details table and account transactions table under schema.They have parent child relation exist. if i filter accounts from account details the corresponding transactions in account transactions table should be filterd.How to achieve this?
    Regards,
    Venkat Vadlamudi
    Mobile:9850499800

    Try with USER_DEPENDIENCIES
    select * from user_dependencies

  • How to create parent and chile process in java

    i'm beginning in java, and i want to ask something, please help me...
    1. i want to ask how to create parent and child process in java???
    example :
    if have one window and explore menu, when i click the explore menu.
    new window come out.
    how if i close the parent window the child window will close too...
    2. what is the method from runtime class to get available memory and Active Threads count

    ONE way to do what you wanted is this.
    class Parent{
    Child c = new Child
    allChildren.add(c);
    //if close
    iterate through list
    (Child)allChildren.get(index).close();
    ArrayList allChildren;
    class Child{
    public void close(){ }
    i dont know if you can get the thread count. but you can
    get the current thread by using System.
    Memory: Runtime.freeMemory() .maxMemory() .totalMemory()
    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html
    Careful though you have to do a calculation to get the
    actual memory because those 3 methods refer to freeMemory
    of the CURRENT heap not the total memory.
    i think its: total - (max - free)

Maybe you are looking for