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.

Similar Messages

  • 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?

  • 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

  • Updating two tables at once

    Dear all;
    I have a table called using_table with the following field
    using_id        life_length          Period
    123                   2                   years
    124                   1                   months
    125                   3                   daysnow i would like a situation whenever the life_length is updated or changed to a new number for the using_table, for instance, the 2 can be changed to 200. If that is the case, this change should be reflected on another table called info_table which has a field column called expiring date. In this table, the expiring date is bascially the mfg date + life_length (period) for that particular id. For example if the mfg date is 01/01/2010 then the expiry date is 01/01/2010 + 2 years(gotten from using_table) = 01/01/2012. Another example is if the mfg date is 01/01/2011 for that id, then expiry date is 01/01/2011 + 1 month (gotten from using_table) = 02/01/2011
    see details of the info_table below
    info_id              using_id                 mfgdate(MM/dd/YYYY)                Expiry date(MM/DD/YYYY)
    A1                       123                          01/01/2010                                    01/01/2012
    A2                       124                          01/01/2011                                     02/01/2011Any help will greatly be appreciated. Thank you.

    You will need 2 triggers for this. The code i am posting DOES NOT account for a multi-user environment. By this i mean if you have 2 users making concurrent modifications to this data YOU WILL get corrupted data. The only way to avoid that it to lock the tables before allowing access to them (the entire table). This means that only 1 session gets to make changes to this data at a time ... you can read about that here
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:474221407101
    As an aside, since you say you are new to Oracle i will share more non-solicited advice with you.
    using_id varchar2(50) not null,
    info_id varchar2(100)primary key,Don't use character data types to store numeric data. It's bad for a number of reason (all of which you can also read about on AskTom).
    Here's the code for the triggers and a simple test case for each.
    create or replace trigger i_dont_like_doing_this
    after update on using_table
    for each row
    begin
       update info_table i
          set i.expiry =
             case
                when :new.period = 'years'
                then
                   add_months(i.mfgdate, :new.life_length * 12)
                when :new.period = 'months'
                then
                   add_months(i.mfgdate, :new.life_length)
                when :new.period = 'days'
                then
                   i.mfgdate + :new.life_length
             end
       where
          i.using_id = :new.using_id;
    end;
    create or replace trigger i_still_dont_like_this
    before insert on info_table
    for each row
    begin
       select
          case
             when u.period = 'years'
             then
                add_months(:new.mfgdate, u.life_length * 12)
             when u.period = 'months'
             then
                add_months(:new.mfgdate, u.life_length)
             when u.period = 'days'
             then
                :new.mfgdate + u.life_length
          end
       into
          :new.expiry   
       from
          using_table u
       where
          u.using_id = :new.using_id;
    end;
    TUBBY_TUBBZ?insert into info_table values ('1', '125', sysdate, null);
    1 row created.
    TUBBY_TUBBZ?select * from info_table;
    INFO_ID                                                             USING_ID                              MFGDATE           EXPIRY
    1                                                                 125                              02-AUG-2010 08 45:51 05-AUG-2010 08 45:51
    1 row selected.
    TUBBY_TUBBZ?update using_table set life_length = 10 where using_id = '125';
    1 row updated.
    TUBBY_TUBBZ?select * from info_table;
    INFO_ID                                                             USING_ID                              MFGDATE           EXPIRY
    1                                                                 125                              02-AUG-2010 08 45:51 12-AUG-2010 08 45:51
    1 row selected.
    TUBBY_TUBBZ?You mentioned in another post that you will disallow modification of the EXPIRY date column by users. I don't know how you plan to enforce this, but unless you have a VERY good design methodology and lots of experience, i really don't see this happening. I'm not trying to berate you, but i remember back to when i was a beginner in Oracle (10 years ago) and that isn't something i would have been capable of.
    10 years later and there's still an exorbitant amount i don't know :(

  • 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.

  • Updating two tables at the same time

    Please,
    Does someone have an idea on how to update two tables at the same times?
    Thanks a lot in advance

    I was thinking about a single session and single update command.
    That's why I thougth someone else could have a clue.
    Thank you

  • How to insert data into two tables at once using XSJS

    Hello Experts,
    My requirement is to insert data into two tables at once. I have a XS JS app and want to update these tables via xsjs. How can I do this ?
    Is there any mechanism like sql 'transactions' also in Hana ? If yes, how can I call it via xsjs ? If not, what are the ways to populate two different tables at once.
    Please advice. Any help is really appreciated.
    Thanks !

    There is nothing special about inserting into two tables at once in XSJS. Just issue two separate SQL Statements.  Don't execute the COMMIT until after both commands.  That way they are all one transaction.

  • How to use one form to update two tables

    How can I do that? HTMLDB wizard or form on table doesn't give me an option to use more than one table in a form or I don't know about it. I created new process which redirects the form to another page after submitting the form. On the second page I created new process which uses the same variables from the previous form page. This process runs on page load before header but it is just not working right.
    So, what is the proper way to update two tables with the same form fields?

    Hello Vikas,
    "The Automatic Row Fetch and Automatic DML processes are a pair, you can't have one without the other."
    Are you sure about that? I have a page, which populate some of the items from TableA, using manual select statement, and after the user input, save some of it in TableB, using Automatic DML. No ARF in this process and it seems to work just fine. Come to think of it, what about a simple form, populated entirely by the user input, and then being saved to the db, using Automatic DML? No ARF here also.
    For the problem in hand, if you can't have more then one Automatic DML per page, I think that the simplest solution will be to define a pl/sql process, with two INSERT statement to the two different tables.
    Regards,
    Arie.

  • How to update a table containing BLOB?

    Hi,
    I'm trying to update two columns in a table.
    one is NUMBER and the other is BLOB
    Is there a way to do so in OCCI in a single operation ?
    the table looks like this:
    CREATE TABLE ACCUMULATORS
    (TARGET_SUBS NUMBER(9),
    ITERATOR NUMBER(9),
    NUMERATOR NUMBER(9),
    LARGE_DATA BLOB,
    PRIMARY KEY(TARGET_SUBS,ITERATOR));
    and the query is something like:
    UPDATE ACCUMULATORS SET NUMERATOR = :x1 , LARGE_DATA = :x2 WHERE (TARGET_SUBS = :x3) AND (ITERATOR = :x4);
    Thanks,
    Menachem

    I had an interview question that is:
    How to update a table (Customer) on a server ex: Report Server with the data from the same table (Customer) from another server ex: Transaction server?
    Set up steps so that inset, update or delete operation gets done correctly across servers.
    I was not sure about the answer, it would be great if someone please put some light on this and explain in details about this process in MS SQL Server 2008 R2.
    Also it would be very helpful if you please describe would it be different for SQL Server 2012? If so, then what are the steps?

  • Updating two tables through JDBC

    <b>Hai,
    Can anybody please answer the following question?
    How can I update two table in Receiver by using JDBC Adapter at receiver side from single source structure.
    Thanks in advance.</b>

    Hi ,
    Create following structure for inbound data type to insert data in DB using JDBC receiver adapter here dbTableName1 is for first table and dbTableName2 for second table .
    <StatementName2>
    <dbTableName1 action="UPDATE_INSERT">
    <table>realDbTableName</table>
    <access>
    <col1>val1</col1>
    <col2>val2</col2>
    </access>
    <access>
    <col1>val11</col1>
    </access>
    </dbTableName1> 
    <dbTableName2 action="UPDATE_INSERT">
    <table>realDbTableName</table>
    <access>
    <col1>val1</col1>
    <col2>val2</col2>
    </access>
    <access>
    <col1>val11</col1>
    </access>
    </dbTableName2> 
      </StatementName2>
    Thanks ,
    Suvarna
    pls award pts if it helps

  • How to update the table available in BADI method

    Hi Friends,
    I have to implement one badi ME_REQ_POSTED for purchase requistion, in this badi  I have to read first line item and do
    some check...if that check is true i need to update subsequent line item (line 20, 30, 40 or so) with purchase group and MRP controller.
    In this BADI i have method POSTED, in this method parameter IM_EBAN is a table which i need to modify with my different
    values for purchase group and MRP controller.
    Kindly let me know how to update this table, so the changes can be reflected in purchase requistion.
    Since when I tried to directly modify the table in a loop, system throw one error stating IM_EBAN can not be modified.
    kindly help.
    pradeep

    hi
    I have implemented this exit but it does not stop at it while saving Purchase requistion. But my previous BADI stops at it when saving.
    Kindly guide.

  • How to update the table value in the valuechange event?

    I have an input field in the datatable with the valueChangeListener
    <rich:dataTable id="cart" value="#{cart.cartList}" var="item">
    <h:inputText value="#{item.cost}" id="qty" valueChangeListener="#{items.updateCost}" onchange="submit()">
    <h:outputText value="#{item.errorMsg}"> </h:outputText>
    in the backing bean
         Item item = (Item) model.getRowData();
    // do some update, if the cost too larger, change to max_cost
         item.setCost(max_cost);
         item.setErrorMsg("Error Msg");
    After calling the valuechange method, the screen output doesn't update the cost.
    How to update the table value in the valuechange event?

    As you're misusing the valueChangeListener to set another input field, you need to skip the update model values phase. Otherwise the value set in the valueChangeListener will be overridden by the submitted value. You can do this by calling the FacesContext#renderResponse() inside the valueChangeListener method. This will shift the current phase immediately to the render response phase, hereby skipping the update model values and invoke application phases.

  • How to update a table (CUSTOMER) on a Report Server with the data from the same table (CUSTOMER) from another server Transaction server?

    I had an interview question that is:
    How to update a table (Customer) on a server ex: Report Server with the data from the same table (Customer) From another server ex: Transaction server?
    Set up steps so inset, update or delete operation takes place across the servers.
    It would be great if someone please enlighten me in details about this process in MS SQL Server 2008 R2.
    Also please describe would it be different for SQL Server 2012?
    If so, then what are the steps?

    I had an interview question that is:
    How to update a table (Customer) on a server ex: Report Server with the data from the same table (Customer) from another server ex: Transaction server?
    Set up steps so that inset, update or delete operation gets done correctly across servers.
    I was not sure about the answer, it would be great if someone please put some light on this and explain in details about this process in MS SQL Server 2008 R2.
    Also it would be very helpful if you please describe would it be different for SQL Server 2012? If so, then what are the steps?

  • How to update Spry-table and present the updated table in a div element?

    Hello!
    I am using a very interesting AJAX-framework called Spry when designing a web page. Here the web page is: Link.
    I need some help.
    Every time a new project or shift is added, the changes are written to an xml-file. When the page is reloaded, Spry reads data from xml-files.
    This is caused by this code:
    dsProjects = new Spry.Data.XMLDataSet("timetable/projects.xml", "projects/project");
    dsShifts = new Spry.Data.XMLDataSet("timetable/{dsProjects::url}", "project/shift"); //look inside projects.xml and //extrac xml-file. url
    dsName = new Spry.Data.XMLDataSet("timetable/{dsProjects::url}", "project");
    I call this function that I have written: loadProjectsIntoDivElement ().
    This function does the following: [See attached code.]
    It iterates through the Spry-datastructure and puts the data in a table inside of the div-element called 'projectsList'.
    Now, when I add a new project, I want it to be inserted into the Spry-datastructure and then cause the new data to be written into the div element called 'Specials_DIV'.
    I have found out how to update a Spry-datastructure (e.g. dsProjects above), but I don't know how to update the table containing the data without refreshing the page. This should be done using Spry.
    Some code:
    1:
    2:
    3:
    function loadProjectsIntoDivElement () {
    $('#projectsList').html('');
    $('#projectsList').append('<table id="Specials_Table"><tr><th spry:sort="id">ID</th><th spry:sort="NAME">Name </th><th spry:sort="hoursestimated">Nr. of hours estimated</th><th spry:sort="hoursworked">Nr. of hours worked</th><th spry:sort="costperhour">Cost per hour.</th></tr>{function::init_hours}<tr spry:repeat="dsProjects" onclick="chooseProject({ds_RowID})"><td>{id}</td><td>{NAME}</td><td>{hoursestimated}</td><td>{hoursworked}</td><td>{costperhour}</td></tr></table><br/>{function::get_hours}<br/>');
    I have tried to accomplish this in various ways but I don't succeed.
    I want to do it without refreshing the page.
    Update: I found some code here that I will try: Link
    Thanks in advance!
    Anders Branderud
    My blog

    Hello!
    Thanks!
    I don't succeed with the implementation in any browser.
    I have found a way to it, but I would like a way that updates the data quicker and without reloading all of the page. After all, I am only adding one row on the end of the data structure, so there should be no need to read in all data again.
    Now I do it like this:
    When a project is added, do this:
    1. Store a new row in the project file through a php script.
    2. When the post-call to the php-file returns, do refresh of the whole page.
    Then the newest version of the xml file will be read in.
    However, I don't want to read the data from a xml file each time that a new project is created.
    I know how to add the new data to a Spry-datastructure [in my code 'dsProjects'], but I don't know how to display the updated data without reloading the whole page.
    I have tried some various ways to do it, but haven't succeded.
    Thanks!
    Anders Branderud

  • Can you really update two tables in one SQL statement

    Ok a post in the forum has got me awefully curious:
    Can you update two tables in one update statement i.e something like this
    update table a , b
    set b.<column> = something
    a.<column> = something
    Something to this effect.
    If you are curious to know what post I am talking about it is called "updating a single row"

    No. You can only update one table in one SQL statement.

Maybe you are looking for

  • Using a Bind Variable in the FROM part of a SQL Statement?

    Hello Everyone, I have a problem, I am trying to run an SQL statement. However I need the FROM part of the SQL statement to be a bind variable. This is because the end user will need to select between 2 database views. I have tried this: select CON_I

  • Open save dialogue box wehn run servlet program

    hi, i m having one servlet file(Write_File.java).. in this prog i retrive some data form one table and write into one file(c:\\write.be).. its automatically stored tat file in server machine.. now what my issue is when i run Write_File.java, it sholu

  • With FireFox 3.6.12 (ubuntu) Google Docs does not allow me to log in.

    Using FireFox 3.6.12 (ubuntu) I can not successfully access Google Docs. All my other Google accounts seem to work under FireFox, just not Google Docs. Google Docs currently works on other platforms like Chrome so this seems to be FireFox specific.

  • Unwanted spaces at top of columns using Dreamweaver 4

    In working on a homepage I manage with one wide and one narrow column, chunks of space intrude themselves at the top of either or both columns. I try adding and deleting spaces at the bottom. I also use modify-table-clear cell heights. Any idea what'

  • Where does Premiere Elements 8 store files?

    I recently bought a new computer and installed Elements 8 on it. I was in the middle of a video project in 7 on my old computer, had a project folder on my D drive with what I thought contained all my photos and captured video. I moved that folder to