How to update two tables with trigger

Hi:
how to update two tables with trigger ?
I have two tables :
(1)ASIA
MI number;
(2)ASIA_P
ID number;
When I insert a new value into the asia.MI ,I also can
insert the same value into the asia_p.id field.
I have write a trigger as follows but it does't work.
create or replace trigger MI_TRG
before insert on asia
for each row
declare
seq number;
begin
select MI_SEQ.Nextval into seq from dual;
:new.MI:=seq;
insert into ASIA_PRO(MI_ID)
values
(seq);
end MI_TRG;
How to realize it ?
thanks
zzm

Why do you say it does not work?

Similar Messages

  • How to update two tables in a single call using JDBC Sender adapter

    Hello All,
    The scenario is, database entries have to be selected from two tables and at the same time those tables have to be udpated with the flag.
    We are using JDBC sender adapter and in Select Query, we are fetching the data by joinin the two tables.
    Update Statemtent: We can only update one table using this statement.
    Is it possible to update two tables using the Update Statement without using Stored Procedures.
    Let me know.
    Regards,
    Sreenivas.

    Hi Sreenivas,
    > Is it possible to update two tables using the Update Statement without using Stored Procedures.
    Yes its possible through join statement
    Check this links
    Update in JDBC Sender adapter for more than one table
    data from 2 tables for jdbc sender adapter
    Regards
    Ramesh

  • How to update Nested tables with xsu

    Hello,
    I have three tables.
    1) DEPARTMENT_TAB
    2) EMPLOYEE_TYP
    3) ADDRESS_TYP
    ADDRESS_TYP is a collection and it is nested inside EMPLOYEE_TYP.
    EMPLOYEE_TYP is a collection and it is nested inside DEPARTMENT_TAB.
    created with below scropt
    CREATE TYPE ADDRESS_TYP AS OBJECT (CITY VARCHAR2(10), STATE VARCHAR2(2));
    CREATE TYPE ADDRESS_TYP_NT AS TABLE OF ADDRESS_TYP;
    CREATE TYPE EMPLOYEE_TYP AS OBJECT (EMPNO NUMBER(4), ENAME VARCHAR2(10), ADDRESS_VAR ADDRESS_TYP_NT);
    CREATE TYPE EMPLOYEE_TYP_NT AS TABLE OF EMPLOYEE_TYP;
    CREATE TABLE DEPARTMENT_TAB (DEPTNO NUMBER(4), DNAME VARCHAR2(10), EMPLOYEE_VAR EMPLOYEE_TYP_NT)
         NESTED TABLE EMPLOYEE_VAR STORE AS EMPLOYEE_TAB
         ( NESTED TABLE ADDRESS_VAR STORE AS ADDRESS_TAB);
    I inserted two rows in DEPARTMENT_TAB and their nested tables using normalsql. and i generated below xml content using XSU java API
    oracle.xml.sql.query.OracleXMLQuery
    My Question is How to UPDATE a row in ADDRESS_TAB using XSU java API
    oracle.xml.sql.dml.OracleXMLSave.
    (When i was trying to update address_tab nested table's row with xml input file. it is deleting other existing rows)
    Thanks.

    Why do you say it does not work?

  • Insert into two tables with trigger on PK in second table

    Hi evereone, ineed help.
    I have two tables (organizations, addresses).
    On addresses table i have trigger on PK. When i do insert i must get this param and insert into OrganizationTable for reference.
    Without ADF i can do insert with returning on addresses, than do insert on organizations with this returning param. How can i do this in ADF business logic using trainTaskFlow?
    Thanks all.
    Edited by: WaterStream on 15.10.2012 15:10

    thanks for reply, but i found solution in this materials:
    http://liuwuhua.blogspot.com/2010/11/master-detail-crud-in-adf-bc.html
    (on this link anyone can download model and see all params)
    but in my project i will get JBO-25030 error.
    Solution founded here:
    http://vtkrishn.com/2011/02/09/oracle-jbo-invalidownerexception/
    Work great!!!

  • How to join two tables with no similar columns

    Hi all,
    I have two tables as follows:
    Table T1 have Attributes as follows:
    GLCODE,
    BRANCH,
    ITEM_NUMBER,
    DEMAND_DATE,
    QUANTITY,
    SOURCE
    Table T2 have Attributes as follows:
    FORECAST_DATE
    Now in SQL if run the following stattement iam getting out put.
    SELECT GLCODE,BRANCH,ITEM_NUMBER,DEMAND_DATE,QUANTITY, SOURCE,(SELECT DISTINCT FORECAST_DATE FROM T2) FROM T1
    The above SQL Statement giving correct results for me.
    The same SQL Statement how can we implement in mapping level?
    Regards,
    Ava

    Jaap van,
    >
    You have to specify an outer join, but how do you do that if there is no join to begin with? I would do the following (which I didn't test yet):
    add an extra column (say C_JOIN) to the T2-ingroup of the join operator and fill it with from a constant operator with say value 1. Then use T2.C_JOIN (+) = 1 as the join condition.
    If every record in T2 is guaranteed to have the same value, instead of using a deduplicator, which will read all records, sort them and deduplicate them, you can use a filter with filter condition ROWNUM < 2, which only will read one record.
    I am facing almost the same problem but not entirely thou and I was wondering if you have an idea how to even start.
    Problem:
    I got this table:SQL> desc ita.tpis32_job_status
    Name Null? Type
    JOBID NOT NULL NUMBER
    T1_ID NUMBER
    QID NUMBER
    REQ_TYPE VARCHAR2(10)
    SUBMIT_TIME DATE
    OWNERID VARCHAR2(30)
    DESCRIPTION VARCHAR2(150)
    STARTTIME DATE
    ENDTIME DATE
    STATUS VARCHAR2(50)
    ERROR_ID NUMBER
    TABLE_NAME VARCHAR2(30)
    SERVER_ID VARCHAR2(10)
    DATABASE VARCHAR2(20)
    PRIORITY NUMBER
    NUM_LINES NUMBER
    PROCESS_ID NUMBER
    QUE_TIME NUMBER
    STATUS_CODE NUMBER
    ERROR_MSG VARCHAR2(500)
    NUM_LINES_TS NUMBER
    REMOTE_STATUS NUMBER
    This the above table, i am looking for JOBID (a five digit number) like 25875.
    What I want to do is add or append this five digit number to a string to find the corresponding table in dba_tables or all_tables. The only way I have try to do this is by writing PLSQL as you see from here:
    Re: Use PLSQL to delete tables dynamically
    When the select is writing properly, the result of the five digit number from JOBID and the string should look like the below result (job_(five digit_%).
    My problem is there is no relationship between ALL_TABLES and the my own table (ita.tpis32_job_status). Any help will be appreciated.
    TABLE_NAME
    JOB_58871_OUTDATA
    JOB_58868_TS
    JOB_58868_OUTDATA
    JOB_58867_TS
    JOB_58867_CMDLBL_2
    JOB_58867_OUTDATA
    JOB_58866_TS

  • How to update a table with strin that contains &

    Hi,
    I would like to update ename col of emp table with a string that contains &
    update emp set ename = 'tom&jerry' where empno = 7369But this gives an error.Please advice.
    Regards,

    Consult the sql*plus reference manual on how to disable the &
    Software engineers should be capable of doing research themselves, please stop abusing this forum to increase your salary by being spoon fed for free.
    Sybrand Bakker
    Senior Oracle DBA

  • How to Update EKPO table with enhancement at header level-customer data tab

    Experts,
    I have a requirement where I had to create a new button in the 'customer data' tab(header) in the ME21N/ME22N Transaction and once it gets clicked a table control will appear and in that all the line items with item no, material and plant and an additional check box will display, and once any one checks the check box against the item/material in the table control the item data with additional z fields (already created the zfields in EKPO Table) should get updated.
    Displaying Table control and item data on the click of button was successful, but once you check the check box against the item and save the PO it is not updating the z-fields in the EKPO table.
    I have implemented all the user exits , badis but no results. 
    Once you check the box in the table control against each item in the header part (Table control is in header part (customer tab)) the line item EKPO table with z fields should get updated.
    Any Clues/ideas will be appreciated.
    Thanks in advance,
    Kalikonda.

    Hi,
    Can you please share the remedy for above issue, recently we have same issue in our system.
    or please send me any supportive doc. for the below mail
    Looking forward for your positive response.
    Thanks
    Mohan
    ([email protected])

  • How to update a table with huge data

    Hi,
    I have a scenario where I need to update tables that are having huge data (each table is having more than 10,00000)
    I am writing this update in PLSQL block.
    Is there any way to improve the performance of this update statement? Please suggest...
    Thanks.

    user10403630 wrote:
    I am storing all tables and columns that needs to be updated in tab_list and forming a dynamic qry.
    for i in (select * from tab_list)
    loop
    v_qry := 'update '||i.table_name||' set '|| i.column_name ' = '''||new_value||'''' ||' where '||i.column_name = ''||old_value||'''';
    execute immediate v_qry;
    end loop;Sorry to say so but this code is aweful!
    Well the only thing to make this even more slow would be to add a commit inside the loop.
    Some advices. But I'm not sure which one works in your case.
    The fastest way to update a million rows is: write a single update statement. On typical systems this should only run for like a couple of minutes.
    if you need to update several tables then write a single update for each table.
    If you have different values that need to be updated then find a way how to consider those different values in a single update or merge statement. Either by joining another table or by using some in-lists.
    e.g.
    update myTable
    set mycolumn = decode(mycolumn
                                     ,'oldValue1','newvalue1'
                                     ,'oldValue2','newvalue2'
                                     ,'oldValue3','newvalue3')
    where mycolumn in ('oldValue1','oldvalue2','oldvalue3'....);If you need to do this in pl/sql then
    1) use bind variables to avoid hard parsing the same statement again and again
    2) use bulk binding to avoid pl/sql context switches

  • How To Update two tables at once

    Hi,
    I have to join two tables for an update. Is it possible to update both tables in one update statement? Thank you.
    UPDATE table_a a, table_b b
    SET
    a.name = 'Tom',
    b.city = 'New York'
    WHERE
    a.id = b.id

    Is it possible to update both tables in one update statement? That's not possible.

  • How to update application table with notification id

    What is the best method for updating an application table with the notification id of a notification just generated.
    We tried creating a suspended activity with a delay but it only works randomly. Sometimes the suspended update activity runs before the notification is generated and the update fails. Thanks, Tom

    Well, you could do a select in WF_NOTIFICATIONS and check if you application table is updated.
    select NOTIFICATION_ID from WF_NOTIFICATIONS where MESSAGE_TYPE like 'item type name'
    But as you noticied, notification id is not created immediately.
    Hope could help.
    Regards,
    Luiz

  • How to update database table with key field?

    Hello Experts,
    I have a database table with following fields
    MATNR   - Key
    SSOUR  -  Key
    KUNNR   - Key
    MENG1 
    MENG2
    MENG3
    And this table contains records like...
    MSD50001     R      1000001     5.30    2.30    5.25
    MSD50002     R      1000002     5.30    2.30    5.25
    MSD50003     R      1000003     5.30    2.30    5.25
    MSD50005     R      1000004     5.30    2.30    5.25
    MSD50004     R      1000005     5.30    2.30    5.25
    I have an internal table with same fields of above database table.
    MSD50001     A      1000001     5.30    2.30    5.25
    MSD50002     A      1000002     5.30    2.30    5.25
    MSD50003     A      1000003     5.30    2.30    5.25
    MSD50005     A      1000004     5.30    2.30    5.25
    MSD50004     A      1000005     5.30    2.30    5.25
    MSD50006     A      1000006     5.30    2.30    5.25
    I want to update the DB table with following internal table records.
    If internal table records = db table records are same then Update....else insert from internal table to db table.
    But here, SSOUR is key field so i am not able to use
    MODIFY dbtab from itab.
    It results me , entries in internal table are inserted into db table.
    So i have double records.
    Is there any statement which updates the key field? and if no fields in db table then insert it?
    Regards
    RH

    hi,
    u cannot update akey field.u can update only non key fields by using key field as a selection criteria.For example if u go to sm30 if u enter any table for inserting values, the key field will always be greyed out it is not succumbed to chnges.but u can insert value into ,if ur inserting and in the insert staemnet if  u have key field which is already present in the table it will return sy-subrc = 4 otherwise it will insert the record and return 0.
    eg for update :
    UPDATE zdm_wtyprof  SET upload_status = 'S'
                             WHERE spart = wa_upd-spart.
    here spart is the key field and it will update the status field in the table as S.
    if updated succesfully it will return 0.
    SIMILARLY U CAN USE select.

  • How to update a table with if condition

    here is my table 
    Party1 party2 DELFlag
    JON     NYC     0
    JON     NYC1   0 
    SAM     NYC   0
    SAM    NYC1   0
    TOM     NYC1   0
    GIT      NYC1   0
    No I need to change all NYC1 to NYC , but I get primary key error As JON is already related to JON->NYC  in this case I need to make the flag to 1 
    To be more specific JON->NYC1 must be JON-NYC1-1 and TOM-NYC1-0 must change to TOM-NYC-0 as tom does not have any records 
    My table update must look like 
    Party1 party2 DELFlag
    JON     NYC     0
    JON     NYC1   1
    SAM     NYC   0
    SAM    NYC1   1
    TOM     NYC   0
    GIT      NYC   0

    I can't use this INSERT INTO @partyRock (Party1, Party2, DELFLag) VALUES my table has thousands of rows and other relations even 
    Dont want to create a new table as this is in all my prod servers , want to update 
    Party1 party2 DELFlag
    JON     NYC     0
    JON     NYC1   0 
    SAM     NYC   0
    SAM    NYC1   0
    TOM     NYC1   0
    GIT      NYC1   0
    SDS      ORD 0
    DED      MEX  0
    Update output table
    Party1 party2 DELFlag
    JON     NYC     0
    JON     NYC1   1
    SAM     NYC   0
    SAM    NYC1   1
    TOM     NYC   0
    GIT      NYC   0
    SDS      ORD 0
    DED      MEX  0

  • How to update two tables at the same time using jdbc

    Plz will anybody tell me what is the code or query in jdbc by which you insert entry in one table and simultaneously it goes in another table?
    Thanks in advance

    You might be
    able to design a trigger to do what you're talking
    about, but that would be a database thing, not a java
    thingAnother option would be an updatable view (google for usage), but it has limitations and should be used with caution. And yes, its a database thinggy and not java.
    cheers,
    ram.

  • How to Update ESTMJ table with appended fields

    Attempting to do a mass load of data to table ESTMJ. Tried using an LSMW, but took a very long time...days in fact. Added a couple Z fields to this table in an append structure. Attempting to run BAPI_BUS1077_CREATE to add records, but how do I update the new Z fields using this BAPI?

    Hi,
    the af:column allows you to group columns
    <af:column>
    <af:column> </af:column>
    <af:column> </af:column>
    </af:clomn>
    Also, in HTML it is easy to assign a background color to cell, e.g. cell with Label 1 is red, Label 2 is green.
    Is there something like this in JSF?
    You can use CSS on the inlineStyl or contentStyle property to dynamically set CSS using EL. You can reference e.g. a managed bean , access the #{row} variable within the managed bean method and return the color based on the value you read for the each row
    Frank

  • How to update database table with this new internal table

    hi
    i have a internal table having 8 records and it contains one record which was modified by user
    not i want this new record to be updated to the database table which was modified by the user
    how to do it pls suggest?
    i want to use index for comarision as using index will not have any problems like promary key etc
    like i want to capture the index for this table which was modified thr recoed index and use thi record indext to modify the database table
    or any other suggestion
    regards
    nishant

    Hi Nishant,
    Have an additional field in a table to indicate a change with which you avoid in updating the record modified by user.
    Regards,
    Madhu.

Maybe you are looking for