trigger after insert in tables MASTER DETAILS, adding bonuses to employees

Hi Experts, I am a beginner in PL/SQL and triggers
=========================
I have two tables:
MASTER (DOC_NO, DOC_DATE, BONUS)
DETAILS (EMP_NO, EMP_NAME, EMP_BONUS)

I need to distribute the (BONUS) column in table (MASTER) to column (EMP_BONUS) in DETAILS

by equal parts.

I need it in (trigger after insert)


EMP_BONUS: is BONUS count (EMP_NO);.

example:
BONUS = 100
No EMP_NO = 20

This means (EMP_BONUS = 100/20 = 5).


I use the 6.0 with 9i DB form
Help, please

RARA says:
Hi Experts, I am a beginner in PL/SQL and triggers
=========================
I have two tables:
MASTER (DOC_NO, DOC_DATE, BONUS)
DETAILS (EMP_NO, EMP_NAME, EMP_BONUS)

I need to distribute the (BONUS) column in table (MASTER) to column (EMP_BONUS) in DETAILS

by equal parts.

I need it in (trigger after insert)

EMP_BONUS: is BONUS count (EMP_NO);.

example:
BONUS = 100
No EMP_NO = 20

This means (EMP_BONUS = 100/20 = 5).

I use the 6.0 with 9i DB form
Help, please

If you want to do after insertion and forms... You can use the trigger to insert after and try something like this

declare
 a number;
begin
select count(emp_no) into a
from master;
update details
set emp_bonus=:bonus/a;
commit;
end;

Hope this helps

If someone useful or appropriate, please mark accordingly.

Tags: Oracle Development

Similar Questions

  • Trigger after insert

    After an insertion in table 1, I want to take the value of the transaction and use it in a custom to insert trigger in an another datbase 2 values. One is the primary key of the table 1 transaction value and the other is a variable of the connected user's session. I can get the value of the user of the session, but I can't get the value of the transaction field.

    $updateRequestDate = "INSERT INTO request_notify (id_request, username) Values ({rsrequest.id_request}," ".). $_SESSION ["kt_login_user"]. "')";
    $update_result = $tNG-> connection-> execute ($updateRequestDate);
    {if(!$update_result)}
    $updateError = new tNG_error ("' error affecting the logged in State to N ', array(), Array();")
    Return $updateError;
    } else {}
    return null;
    }

    I have the custom trigger after insert transaction.

    How do you get the value of a transaction for a custom trigger field?

    Please try with the help of the

    $tNG-> getColumnValue ("column_name")

    method instead.

    See you soon,.

    Günter

  • Create the trigger after insert

    Hello

    I would like to ask how to create a trigger after insert on a table. Basically, what I wanted to do are when an insert to table1 it will insert the records to table2. But the problem is that folders that will be inserted in the new tables are entries/fields, who lived in NEW York City (on table of ld)

    after insertion, I wanted to add another field in table2 as status


    create table table1)

    Name varchar2 (55),
    City varchar2 (55)

    );

    create (table2)

    Name varchar2 (55)
    status int (1)
    )

    Hope you could help me.

    Thank you

    Best regards

    antok1015 wrote:
    Hello

    I would like to ask how to create a trigger after insert on a table. Basically, what I wanted to do are when an insert to table1 it will insert the records to table2.

    It's easy...

    SQL> create table table1(
      2    Name varchar2(55),
      3    City varchar2(55)
      4  );
    
    Table created.
    
    SQL>
    SQL> create table table2 (
      2    Name varchar2(55),
      3    status number(1)
      4  );
    
    Table created.
    
    SQL>
    SQL> create or replace trigger trg_tbl1 after insert on table1
      2  for each row
      3  begin
      4    insert into table2 values (:new.name, 1);
      5  end;
      6  /
    
    Trigger created.
    
    SQL> insert into table1 values ('Fred','Bob');
    
    1 row created.
    
    SQL> select * from table2;
    
    NAME                                                        STATUS
    ------------------------------------------------------- ----------
    Fred                                                             1
    
    SQL>
    

    But the problem is that folders that will be inserted in the new tables are entries/fields, who lived in NEW York City (on table of ld)

    after insertion, I wanted to add another field in table2 as status

    This is not sensible. Please explain what you mean.

  • 11g - partial trigger on table master / detail does not

    Hello

    I do slip and fall a child vo to a page as a 'master table of detail. " It creates two tables, one for the parent and the other for the child. The childTable has parentTable as his partial trigger, when the selection on modified parentTable, childTable the data as changed.
    Now, all this is broken when I join parentTable with panelCollection. The error in the editor said that the childTable cannot find any component with the id indicated in the partialTrigger property.
    So, how can I enable 'partialTrigger' ing when using panelCollection?
    Thank you.

    Kind regards

    Rudi

    Click the Edit to the partialtrigger option and then browse to choose your table.
    Note that you need to provide an I would for bounding Panel collection first.

  • Problem of initial insertion of form master detail on the subregion details

    Hello

    I created a master form details to the report which should make insertion on the master and detail region or subregion.
    Insert mode, I come home with block of main data and details, when I press the 'Create' button, insert happen only on master block (table command) and the retail block (table ORDER_ITEM).

    The EDIT mode for that inserts/updates on main block and without problems.

    Request Express 4.2.1.00.08
    Oracle Database 11g Express Edition Release 11.2.0.2.0

    I appreciate your help.

    Concerning

    Something like this should do the job:

    CREATE OR REPLACE TRIGGER order_item_table_tr
       BEFORE INSERT
       ON order_item_table
       FOR EACH ROW
    BEGIN
       IF :NEW.order_id IS NULL
       THEN
          :NEW.order_id := v ('P1_ORDER_ID');
       END IF;
    END order_item_table_tr;
    /
    

    To ensure that the treatment of automatic line (DML) the order table returns the key in question > return to key item > P1_ORDER_ID (or however the primary key of the table order is named)

    Denes Kubicek
    -------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.Apress.com/9781430235125
    http://Apex.Oracle.com/pls/Apex/f?p=31517:1
    http://www.Amazon.de/Oracle-Apex-XE-Praxis/DP/3826655494
    -------------------------------------------------------------------

  • Problem with trigger AFTER INSERT

    Hi all

    I am updating a column in the table by adding 2 characters 'a_' after INSERTION using the trigger.

    Now when I insert data in the table a trigger is fired for INSERTION.
    According to the syntax, I think that we cannot pass parameters in a trigger.
    I have a test10 table that looks like this.
    t1    varchar2(10)
    t2    varchar2(10)
    t3    varchar2(10)
    t4    number
    t5    number
    
    t1 is kinda primary_key and t2 is unique though the table isn't structured like that but the data in it follows that.
    The code in the trigger looks like this 
    
    CREATE OR REPLACE TRIGGER test10_t1 
      AFTER INSERT 
      ON test10 
      FOR EACH ROW
    BEGIN
      IF INSERTING THEN
        UPDATE test10 SET t1 = 'a_'||:old_value WHERE t1 = ?;  -- I need to mention the parameter here but not sure if we can pass param in a trigger 
      END IF;
    END;
    If I omit the WHERE clause, all records are updated. Is there another way to solve the problem?

    THX
    Rod.

    There is no need to use a clause of update.

    Have you tested the relaxation that I suggested in my last post?

  • MapView - Table | Master detail

    Hello

    I have a plan and I need to update a table accordingly to what the user selects on the plan. For example, the user clicks on a State on the map and watch the State news. I tried to use master detail that connects between the map and the table but I don't seem to work. Does anyone have a suggestion or a workaround?

    Thanks in advance,

    William Janoti

    Probably you have not added State column in Table guest section of the table display. Or maybe the status column in the view map and table are mapped to the columns of different logics.

    Its pretty simple and I never found problems with master-detail map to the Table.

    Thank you

  • Trigger AFTER INSERT or UPDATE run twice

    Hi people! I have a problem with this trigger, if I insert a record, INSERTING run 2 times still, I guess that the problem is in AFTER INSERTION or UPDATE of THE SAL ON EMP, but I can't find the solution, I m used to read a lot but nothing... Any idea? Thank you and sorry my bad English.

    PD: I use oracle database 9i 9.2.0.1.0 enterprise

    CREATE OR REPLACE TRIGGER TEMA10EJER1
    AFTER INSERTION OR UPDATE OF THE SAL ON EMP
    FOR EACH LINE
    BEGIN
    IF THE INSERTION
    UPDATE DEPT
    PRESUPUESTO SET = PRESUPUESTO +: new.sal
    Where: new.deptno = deptno;
    ELSIF UPDATING ('sal') THEN
    UPDATE dept
    Presupuesto SET = presupuesto -: old.sal +: new.sal
    WHERE: new.deptno = deptno;
    END IF;
    END;

    Check your DEPT table, may be there is another trigger that inserting a new record.

  • trigger for insertion of a table to another table

    Hello again,

    I tried to write a trigger after insert or update will happen in table 1, it will move some values in another table, as shown below:

    Create or replace trigger Insert_Amount_Credit after insert or update on Reciept_Voucher

    Referencing NEW AS NEW OLD OLD FOR EACH LINE AS
    Start

    Insert into customer_Details (Transaction_Date, client_name, Description, credit) values (new. Rec_Date, new. Client_name, CONCAT (' receipt number:', again.) Rec_ID), new. Amount);

    End;

    /

    The trigger was created but with compilation error... and my question is:

    1. How do I write the code above in the best way?

    2. How can I enough the other table with a table concatenated as what I was trying to make above?

    any idea?

    Something like that?

    CREATE OR REPLACE TRIGGER trig_ins_testtrg2

    BEFORE INSERT OR UPDATE ON test_trg1

    FOR EACH LINE

    BEGIN

    INSERT INTO test_trg2 (curr_date,

    job_id,

    reason,

    credit)

    VALUES (SYSDATE,

    : NEW.id,.

    : NEW.receipt_no |:NEW.description,.

    (: NEW.amount);

    END;

  • Master detail form

    Apex 4.0 master detail form

    In my Application

    1 page 2 is the report
    2 page 3's master detail form

    Press the button create on page 2, it displays the page 3 i.e. control the detailed form

    After entering in detail the form master I press the button create is back on page 2 that is create to communicate their data page and master
    but to go into detail for the same record I change and enter on page 3.

    I'm looking for the solution. When I press on create button on the master page 3 it will not return to page 2 page report i.e.
    recode newly created on the same screen (no return on page 2) and appear I get recode in detail for the master above.

    After completing data entry master detail, I will return that is page 2 to report.

    You can also visit my request and suggest but how to solve the problem

    http://Apex.Oracle.com/pls/Apex/f?p=50199:2:3351945796035428:no:

    What happened to change the branching (to be submitted on page 3) page 2 page 3? Or by adding a (conditional) branch on page 3 before this one?
    Maybe with some restrictions (so only when you press the button create).

  • detail record in master-detail of the removal

    Hi all

    I created the table master / detail in oracle form 6i

    It has two tables, now I want to delete the data in my table of detail, how I remove it, I want to just delete a single database at a time

    Thanks in advance

    Thank you
    Aerts.

    As andreas says it should delete record. I think that you created the button outside the block in which you want to remove
    recording. You must write the code like this

    GO_BLOCK ('DETAIL_BLOCK_NAME');
    DO_KEY ('DELETE_RECORD');

    and the time that you want to recalculate again when records are delete. Then, you will have to
    write the code below your inside... I mean right now adding it to first REMOVE deduct.
    something like that...

    -Clément

  • master/detail relationship through two workflow

    Hello world

    I use jdev 11.1.1.7.0.

    In my application, I created a relationship master-detail between departments and employees (departments is master and employees is detail). Then, I created two stubborn workflow.

    Department-stream with a department.jsff and I drag / drop the departmentVO as a form.

    dep.png

    employee-stream with an employee.jsff, on this page I drag / drop employeeVO located under departmentVO in the control panel of data:

    emp2.png

    can I use these two TFs (Department-flow and employee-flow) through two different ways

    1- I create a main.jspx page and I put two TFs as an area on main.jspx.

          <af:form id="f1">
            <af:region value="#{bindings.departmentflow1.regionModel}" id="r1"/>
            <af:region value="#{bindings.employeeflow1.regionModel}" id="r2"
                       partialTriggers="::r1"/>
          </af:form>
    
    

    in this case when I run the homepage, two TFs are in sync with each other, I mean when I navigate between departments in the workflow Department, employees in the employee flows are discount

    and also if I enlist in the workflow Department then changes in the flow of employee will be validated.

    2- in this case first I create a master stream with an master.jsff and then I put two TFs as an area on master.jsff.

     <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
      <af:region value="#{bindings.departmentflow1.regionModel}" id="r1"/>
      <af:region value="#{bindings.employeeflow1.regionModel}" id="r2"
                 partialTriggers="::r1"/>
    </jsp:root>
    
    

    and finally I put flow master as a region on the page main.jspx.

           <af:form id="f1">
            <af:region value="#{bindings.masterflow1.regionModel}" id="r1"/>
          </af:form>
    
    

    in this case, when I run the main.jspx , always the two page two TFs are in sync with each other (updating of employees when I navigate between departments)

    but in this case the validation in the workflow Department commit not changes in the flow of employee.

    Anyone know how I can I have this (validation cause Department-stream flow used as case 1)?

    Habib

    Concerning

    Habib,

    I just did what you said.

    1. Ran the mainWithMasterFlow.jspx,

    2. the Department rendered initially has only one employee.

    3. has changed the salary. (Kept the emphasis placed in the same field)

    4 click "Commit".

    Above scenario failed, because the change in value has not been submitted. Try adding autoSubmit = true for the salary field and then repeat the procedure, you will see the file be saved.

    Rambeau

  • PST: Master / detail graph

    Hello

    JDev Version: 11.1.1.5.0

    I use ADF DVT histograms to view the details of the table master / detail. I found a useful example to: http://www.oracle.com/technetwork/developer-tools/adf/learnmore/057-dvt-master-detail-172847.pdf by Frank. This example contains the master as a bar graph and clicking on a particular bar refreshes the detail with contents of corresponding detail table.

    I would have a similar behavior, but the detail table should be another graph bar instead of a table. Can someone let me know or share some examples to show how to so that the relationship of the master / detail with two bar graphs?

    Thanks in advance
    Rouhaud

    Hello

    creating a begavior of j - m is quite simple:

    (1) slide the parent collection (for example ministries) as a bar to a page chart
    (2) check the box set the pie that is selected as the current line
    (3) drag and drop the dependent collection (e.g. employees) as another graph
    (4) either set changeEventPolicy = ppr in the PageDef file for the iterator employee or
    Set the property PartialTriggers to the widget detail to point to the parent

    Frank

  • trigger to update a table after the use of commit_form;

    Hi, I have a master detail shipping form where I enter the details and use commit_form; to save data... after that I want to update a column named as transit in deteil table
    but the changes are not reflected.
    PROCEDURE transit_update IS
    BEGIN
           if :shipbill.billtype in ( 'Send it to site','Send it to staff','Send it to store','Send it to consumed ','send it to repair')
              then          
              update ship_1 set transit_qty = transact_qty
         where 
         billid =:shipbill.billid;
    
    
         end if ;
         
         if :shipbill.billtype in ('Received from staff','Received from site','Received from store','Received from STC')
              then          
              update ship_1 set transit_qty = 0
         where 
              billid =:shipbill.billid;
         
    
         end if ;
    END;
    I wrote it under the procedure and tried to call the block level under update post trigger but it doesn't...

    Hello
    Why not put the sub condition in PRE-INSERT/PRE-UPDATE (at the level of the blocks) of the retail block?

    IF :shipbill.billtype IN ('Send it to site','Send it to staff','Send it to store','Send it to consumed ','send it to repair') THEN
      :ship_1.transit_qty = :ship_1.transact_qty;
    ELSIF :shipbill.billtype IN ('Received from staff','Received from site','Received from store','Received from STC') THEN
      :ship_1.transit_qty = 0;
    END IF;
    

    If billtype is not simple text (filled in by the user) and then trying to find no matter what other condtion. To reduce misspellings error etc.

    -Clément

  • Master detail form can not insert foreign key

    Hello

    I Master detail form, in the data block master, I Header_ID primary key and it is generated through trigger on the main table and this field is found in the data block but is hidden on the Web, this Header_ID is a key in another table, on the form, I created the main form and has also created the good relationship. now, when the new record is inserted, the Header_ID in the main table is filled properly while in the secondary table that goes with the NULL value. I have no idea how to solve this problem, any help will be appreciated

    Rather than use a database trigger, select INSERT before triggering in the basic data block to fill the HEADER_ID.

    In the before INSERT trigger, you'd have a line like:

    select seq.nextval into :MASTER.HEADER_ID from dual;
    

    When you do this in the before INSERT trigger will fill the element in the block MASTER that feeds in turn the question into the DETAILS or blocks.

Maybe you are looking for