Script for master child relation

we need script for maste child relation
if i insert or delete or update in master table it should reflect in child table after running procedure (not trigger).
fetch the value from master table and insert into child table using cursor.
for ex:
if i insert value in master table tab1 with column name emp_id, it should reflect other child table with the same column name emp_id.
insertions should only be done in master table. not in child table..
notes:it should be in cursor

hallo
This is our procedure.the procedure works fine for loop 3 with cursor c3.
The other cursor 1 and cursor 2 are not working fine. they are fetching duplicate values(ex:D10,D10........).
In this procedure we are fetching values from 3 tables and putting values in a single table.
please find the solution the code is given below.
code
create or replace procedure employee_insert
is
cursor c1 is
select * from department where
not exists (select null from employee where employee.department_id=department.department_id);
p1 department%rowtype;
cursor c2 is
select * from jobs where
not exists (select null from employee where employee.job_id=jobs.job_id or employee.job_title=jobs.job_title);
p2 jobs%rowtype;
cursor c3 is
select * from project where
not exists (select null from employee where employee.proj_id=project.proj_id or employee.proj_name=project.proj_name);
p3 project%rowtype;
begin
for p1 in c1
loop
for p2 in c2
loop
for p3 in c3
loop
insert into employee (EMPLOYEE_ID,EMPLOYEE_NAME,
department_id,department_name,
DATE_OF_BIRTH,job_id,job_title,
HIRE_DATE,
SALARY,proj_id,proj_name,
PHONE_NUMBER,
ADDRESS,EMAIL) values('E'||employee_id_seq.nextval,
dbms_random.string('A', 8),
p1.department_id,
p1.department_name,
TO_DATE(TRUNC(DBMS_RANDOM.VALUE(2452641,2452641+364)),'J'),p2.job_id,p2.job_title,
TO_DATE(TRUNC(DBMS_RANDOM.VALUE(2452641,2452641+364)),'J'),
Round(DBMS_Random.value(10,50)),
p3.proj_id,p3.proj_name,
'98'||'42'||Round(DBMS_Random.value(1000,5000)),
dbms_random.string('A', 20),
dbms_random.string('A', 8));
end loop;
end loop;
end loop;
Exception
When others then
raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
End;
execute employee_insert;
/

Similar Messages

  • Master-Child relations with ODP??

    I don't understand why I am having problems trying to build a simple master-child table relation with cascade delete using ODP .NET. With microsoft's providers, in the FILL command, you can specify the relationship in the fill command - Fill(dataset_name,relation_name). But in ODP .NET, it doesn't accept the relation_name as the second parameter, just the datatable. Why is that? are there any good examples out there that show working with Master-Child relations populated with Fill()? Any help would be greatly appreciated.

    bump

  • Af:tree , have drill down to 10th level,Master child relation.

    Hi ,
    Am using adf 11.1.1.5
    I have two read only vo . which i have created a view link to make Master - Details relation .
    Now i have to show tree structure up to 10th level .
    I have table were one column provided with check box where user select a record like accid and fire menu command button.
    On that fire i wanna show a pop which show a parent id as Parentnode and its related child ids as child node .Again if child has sub child id, i have to show them upto 10th level.
    Any suggestions ..

    i knew somewhere i was messed up .
    There is only viewlink between, Parent and child .NO FK ,these are not related database table (Entity Object.).
    simple query's which are made from same table , but base on Parent/Root col i have show data in tree structure way.
    Just like
    ParentId Chilld id
    100 jhon
    100 max
    100 adam
    101 jack
    103 jill
    103 marven
    Now it will show in table like
    jhon
    max
    adam
    jack
    jill
    marven
    If i click max i mean check box and fire button , i have to show tree structure like below
    100
    jhon
    max
    adam
    As max parentid is 100 , i have to show all the childid which have 100 as parentid.
    any suggestion plz , me struck here to handel

  • Inspection for Parent Child Relation

    Hi
    We are producing Mat.A from Mat .B and you want to copy the results from Mat.B .
    Both materials are batch managed.
    The requirement is - At the inspection for Material A , want to use batch derivation to copy results of Mat B (Parent Child Process)
    Please Guide ..
    Please schare Doc if available ..
    Mayank MEHROTRA
    Or in other words..
    Whether its possible to transfer the characteristics values of the batch from parent materia (MOM Materials)l to Child Materials
    Edited by: Mayank MEHROTRA on Jul 30, 2010 2:19 PM

    Hi Mayank,
    We had the same issue in one project. What we did, we develped a z- transaction and program for that.
    We had child batches, for eg, 1234561,1234562,1234563,1234564. here the mother batch is 123456. so we recorded value for this mother batch in MSC1N. In developed z transaction, we had a field called "mother batch" and next two fields as "from child batch" and "to child batch". So make entry in these fields and execute. Data will be populated automatically.
    Sit with a good ABAPer, he will be able to develop the same.

  • Af:tree Master child relation ,but showing child id's as parent node vice

    Hi ,
    Am using adf 11G 11.1.1.5
    I have a small requiement .
    Am using af:tree , where i display childId's . Onclick of child it i have to show popup with tree structure where i will show parentid as node and childId's as child nodes
    i have created view link between child and parent views.
    Now isssue is when i selected childId in table (i mean a checkbox is given where user check the child Id and fire button ).On dat action am calling popup with tree structure .BUT here childId's are displaying like Parent nodes and parentId's as child node.
    any suggestion . if want i will drop the code

    i knew somewhere i was messed up .
    There is only viewlink between, Parent and child .NO FK ,these are not related database table (Entity Object.).
    simple query's which are made from same table , but base on Parent/Root col i have show data in tree structure way.
    Just like
    ParentId Chilld id
    100 jhon
    100 max
    100 adam
    101 jack
    103 jill
    103 marven
    Now it will show in table like
    jhon
    max
    adam
    jack
    jill
    marven
    If i click max i mean check box and fire button , i have to show tree structure like below
    100
    jhon
    max
    adam
    As max parentid is 100 , i have to show all the childid which have 100 as parentid.
    any suggestion plz , me struck here to handel

  • Master child Package Example package

    Hi Experts,
    Can any of you guys please send some sample packages for master - child packages (dtsx files) which includes all configuration from an xml file to [email protected]?
    XML conf --> Master --> Childs
    I am new to SSIS and i just wanted to have a look at the options in those packages.
    Regards
    mukejee

    Hi Mukejee,
    To setup the association between the parent package and child package, there are two approaches:
    Through passing variables. Specify the child package for the Execute Package Task in the parent package, and then add a Parent package variable type configurations in the child package.
    Through passing parameters. Specify the child package for the Execute Package Task in the parent package, and map the parent parameters and the child parameters. No additional actions are needed in the child package.
    Besides, the XML Configurations for a package is not affected by the factor that whether it is a parent/child package of another package or not.
    Here, I have created two SSIS 2012 packages with the parent-child relationship that you can download from my
    SkyDrive. In the parent package, I create a variable VarMaster with the value “This is a parent package variable.” In the child package, I create a variable VarChild with the value “This is a child package variable”, and use a Script Task to display the
    value of the VarChild variable. You can see that the Script Task returns different values when we run the parent package or run the child package. 
    Regards,
    Mike Yin
    TechNet Community Support

  • Master Child Table

    Hi,
    I am using JDeveloper 11.1.1.4 version.
    In my page I have master child relation to be displayed.
    I am displaying this by following the standard adf-bc master child example.
    i.e add the id of the master child as partialTrigger to the child table.
    But my requirement is that, multiple row selection is enabled for the master table and when multiple rows are selected in master table,
    child table should not display any records.
    How can I achieve this??
    Also,I have a details panel displayed right under master table which displays selected row values in a form.
    Here also,when multiple rows are selected,I should not display any values in the details panel.
    Please advice on how to achieve this.
    Thanks,
    Praveen

    Hi,
    have a selection listener set on tabe to bean method and in bean getAllSelectedRowKeys from table. If you get more than or equal 2 entries hide the detail panel or write code so that u reresh ur detail vo to contain no rows

  • Changing into parent-child relation

    Hi,
    I have a table which has the following fields and the table gives the identifier for parent-child relation:
    ID
    PARENT ID
    structure
    parentkey_field
    foreignkey_field
    Fields[]
    data[]
    1.ID is the numbering like 1,2,3...
    2.PARENT ID will give the relation like which structure is the child for which   structure.
      Example: I have two structures HEADER and ITEM.Then the IDs will be 1 and 2.The parent id for ITEM will be 1(ID OF HEADER).
    3.Structure is the header/item structure names.
    4.parentkey_field and foreignkey_field are defining the header-child relation identifier fields.
    5.fields[] is the table with all the fields of header and item.
    6.DATA[] is the table having the data of header/item fields.
    Now my requirement is to flatten this table into one more table(with field structure_name,fieldname,value) with parent-child relation.
    Can anyone suggest something.

    It would be better if you posted the code you tried first and then having others help you with what's wrong.  Flattening a hierarchy is not that difficult; why don't you give it a shot first?

  • Scripts for Exporting Master/Work Rep

    Hi,
    I want to automate the export process and in turn was looking for any scripts for exporting the whole ODI Work/Master Rep. I checked the CLASS objects and we donot have any CLASS names for Repository exports.
    Thanks in advance for any answers..!

    Created for 10g [ http://odiexperts.com/automize-the-backup-using-odi-exports]
    but should work for 11g too :)

  • Load Scripts for stress testing any OAF related application

    This may not be the correct forum. However, i'm sure many of you might have used load scripts to stress test your OAF related application.
    Can any of please shed some light on how to make these load scripts for automated testing for finding the performance of OAF appls (like iPro or iExpense)? What tool do we use for these type of Self Serv appls? How can we parameterise some of the session related values inside load scripts?
    Any of your experiences will give me a good start....Thanks

    Answers to these questions are generally dependent on the application server to which you will be deploying, as each application server has its own means of tuning for performance.
    For tuning Sun's App Server 8, see the online Performance Tuning Manual, at http://docs.sun.com/app/docs/doc/819-2561
    // Gregory

  • Calculating value based on parent/child relations for a column..

    Hi Friends,
    I have a requirement thus,
    sample table, parts,
    ppart cpart qty
    990 1234 200
    100 100_1 150
    100 100_2 2
    100_1 120 100
    100_1 121 200
    100_2 130 50
    where qty is a number and the rest are varchar fields. Here the ppart 100 is a parent value for cpart values 100_1 and 100_2. So, I need to multiply the qty value for a child with the parent's qty values. The final result would look like,
    ppart cpart qty
    990 1234 200
    100 100_1 150
    100 100_2 2
    100_1 120 15000
    100_1 121 30000
    100_2 130 100
    I have only a basic understanding of SQL but I couldnt figure out a way for this. My best try was to join the table with itself and equate the ppart and cpart columns to retrieve the qty. However, the actual table has about 50 million records and I guess my idea is not going to please my DBA! I would appreciate if you could suggest better ideas.
    Thanks.

    Hi,
    you forgot nvl()
    SQL> with parts as (select '990' ppart, '1234' cpart, 200 qty from dual union all
      2                select '100'  , '100_1', 150 from dual union all
      3                select '100'  , '100_2', 2   from dual union all
      4                select '100_1', '120'  , 100 from dual union all
      5                select '100_1', '121'  , 200 from dual union all
      6                select '100_2', '130'  , 50  from dual)
      7  select p.ppart parent_part, c.ppart child_part, p.qty parent_qty, p.qty * c.qty child_quantity
      8  from   parts c
      9  left join parts p on c.ppart = p.cpart
    10  /
    PAREN CHILD PARENT_QTY CHILD_QUANTITY                                          
    100   100_1        150          30000                                          
    100   100_1        150          15000                                          
    100   100_2          2            100                                          
          990                                                                      
          100                                                                      
          100                                                                      
    6 rows selected.
    SQL> with parts as (select '990' ppart, '1234' cpart, 200 qty from dual union all
      2                select '100'  , '100_1', 150 from dual union all
      3                select '100'  , '100_2', 2   from dual union all
      4                select '100_1', '120'  , 100 from dual union all
      5                select '100_1', '121'  , 200 from dual union all
      6                select '100_2', '130'  , 50  from dual)
      7  select p.ppart,p.cpart, p.qty * nvl(c.qty,1) qty
      8  from   parts p,parts c
      9  where p.ppart = c.cpart(+)
    10  /
    PPART CPART        QTY                                                         
    100_1 121        30000                                                         
    100_1 120        15000                                                         
    100_2 130          100                                                         
    990   1234         200                                                         
    100   100_2          2                                                         
    100   100_1        150                                                         
    6 rows selected.

  • Multiple Master Detail Relation In Forms 6i

    I have tables as below
    1.Bill_Head
    Bill_No
    Bill_Date
    Fin_Year_Cd
    Remarks
    2.Bill_Tail
    Bill_No
    Product_Cd
    Amount
    Ded_Amount
    Net_Amount
    3.Bill_Tail_Det
    Bill_No
    Product_Cd
    Quantity
    Rate
    Interest_Percent
    Service_Charge
    Vat_Tax_Percent
    The Relation is like
    Between BILL_HEAD and BILL_TAIL is Master Details Relation
    Between BILL_TAIL and BILL_TAIL_DET is one to one relation
    In single form i am not able to insert record.
    If i build Master details between BILL_HEAD and BILL_TAIL, BILL_TAIL and BILL_TAIL_DET, when i run the for to insert data.
    I will put the data for BILL_HEAD data
    For this parent record there will be child record in BILL_TAIL block.
    For this BILL_TAIL parent record there may be a child record in BILL_TAIL_DET or may not. Suppose i put a child in BILL_TAIL_DET.
    Then i wanted put one more child record in BILL_TAIL block, if i say next record, it is asking me to "save the record first".
    Please help me in this regards
    my mail id : [email protected]
    Regards
    Mahaveer
    Message was edited by:
    user603318

    Thanks Kris, for your reply.
    Is there any way out to enter all the data at once and then commit, b'cse for every record asking to commit is tedius.
    Regards
    Mahaveer

  • Master-Detail Relation- Detail records not displaying

    Hi All,
    I am working forms(10g) customization for an oracle applications. our requirement is to develop a new window(screen) which should display all the related child records for the master record in the main form on a button press.
    i have developed a new database block based on a vew and provided the relation with master block, and done the required customization.
    But, when i run the form, and clicked on button, it is giving an error
    FRM-40350 Query caused no records to be retrieved.below is the code that i have written on button click
    BEGIN
              IF event = 'WHEN-BUTTON-PRESSED'
              THEN
              SHOW_VIEW('XXSCP_GBL_CUST_PEGGING_CON');
              SHOW_VIEW('XXSCP_GBL_CUST_PEGGING_STK');
              app_window.set_window_position('XXSCP_GBL_CUST_PEGGING_WIN',
                                             'CASCADE',
                                             'XXSCP_GBL_EXCEP_DETAILS_WIN');
          SET_BLOCK_PROPERTY('XXSCP_GBL_EXP_DETAIL_V',NEXT_NAVIGATION_BLOCK,'XXSCP_GBL_CUST_PEG_V');                                        
          GO_BLOCK('XXSCP_GBL_CUST_PEG_V');
         -- fnd_message.DEBUG('before execute');
          EXECUTE_QUERY;
          :parameter.p_excep_detail := 'FALSE';
              ELSE
                   NULL;
              END IF;
              EXCEPTION
                   WHEN OTHERS
                   THEN
                   fnd_message.DEBUG('other error at button press'||SQLERRM);
              --     NULL;
    END;I am able to query records in my view from database, but not working when i run the form.
    ANy suggestion will be helpful.
    Thanks in advance,
    pavan

    Duplicate post -- Re: Master-Detail Relation- Detail records not displaying

  • Forms Builder Master Child relationship --- column datas gets hided.

    Hi All,
    I have a screen which have 5 columns. Out of which first 3 columns belong to Table A and 4th column belong to say Table B and the 5th column belong to Table C. There is a master Child relationship between Table A and Table B also between Table A and Table C.
    The issue is, i enter the data for these columns in row wise. I enter all 5 columns with value and when i switch to next row, the 4th and 5th column's value gets hided.
    Please suggest.
    Thanks and Regards,
    KirthiRavi

    KirthiRavi wrote:
    Hi All,
    I have a screen which have 5 columns. Out of which first 3 columns belong to Table A and 4th column belong to say Table B and the 5th column belong to Table C. There is a master Child relationship between Table A and Table B also between Table A and Table C.
    The issue is, i enter the data for these columns in row wise. I enter all 5 columns with value and when i switch to next row, the 4th and 5th column's value gets hided.
    Please suggest.
    Thanks and Regards,hI KirthiRavi
    You have relation with
    Table A with Table B
    Table A with Table Cwhen you switch a record to another record at bloc/table A, it's normal forms behavior it's will hide value of block/table B and C. when your click on associate row of block/table A it will show.
    It's the form normal behavior for relationship.Hope you understand.
    Hamid
    Mark correct/helpful to help others to get right answer(s).*

  • Ran CATT Script for the role assignment to users

    Hi All,
    I have ran ECATT script for doing role assignment in QAS and completed successfully. I did this through CUA. What is the next step after running catt script? Do I need to doing anything with PFUD in each child system? Because I checked in the child systems many derived single roles are not generated in QAS.(RED). Is it because of running catt script or it might have came like that only from development? Please advise..
    Regards,
    Masood

    >
    Salman123 wrote:
    > Please let me know how should I proceed from here
    Hi,
    I have told you why the error message is there.  What do you not understand about the resolution? Your parent roles are out of sync with the child roles so you need to re-sync them.   An example of how do do this is to "adjust derived" from the master role.  Only when you have done this will your roles be in sync again.

Maybe you are looking for

  • When belle refresh update on nokia n8

    my product code 059c8t6 when its going to get the belle refresh update Solved! Go to Solution.

  • Putting 'Stop' markers in a sequence to be controlled  in indesign

    Hello; Does anyone know a way of having a video that has 'stop' markers placed in the timeline, so that the playback stops at that point, unless the user clicks the 'next' button (that i would set up in Indesign, as this will be an interactive PDF) I

  • Service Po table

    Dear all,              In service po ESLL table there is no PO Number. SAY example i wanted to know wat r all the service pending po's.  i can get all the datas except ESLL. becos int his table there is no po no. pls tel me  ESLL table LINK WITH othe

  • Fault message

    where and how we will use fault message? is that we will use it in proxy scenarios only?

  • Need to stop charging battery if I conncted iPhone to the PC

    Hi every body Sometimes I need to connect my iPhone to iTunes to install apps or movies but I don't want to charge the battery ... as I know it is bad practice to charge the battery if not empty of very low. so is there any way to stop charging from