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.

Similar Messages

  • Can you back up two phones on one itunes account?

    I have just purchased an iPhone5s and want to transfer all of my information from my iPhone4s onto it. I was told that this could be done by first backing up my phone using itunes. Sounded simple.
    Now i am having great difficulties!
    My wife nacked up her phone earlier this year. Every time i go to back up my phone (turning on itunes and then plugging my phone in via usb) it comes up with two options - set up as a new iphone OR restore from my wife's phone.
    I am really unsure what to do here. I fear losing all the data on my phone.
    Is it possible for the one itunes account to back-up two phones?
    Please help.
    Thank you in advance.

    Select setup as "New", the next screen should prompt you to rename your phone. Just name it what you already have it named. After that, you should be able to sync/backup and all of your data & settings will still be exactly as you've already set them up on your phone. That message is more threatening than what really happens.

  • Joining two tables using PL/SQL

    here i am trying to join two tables can any one tell me what is wrong with this syntex
    CREATE OR REPLACE PROCEDURE test IS
    CURSOR c1 IS SELECT seq,fname,lname from t1;
    CURSOR c2 IS SELECT seq1,q,a from t2;
    userjob number;
    BEGIN
         OPEN c1;
    insert into t3 values(c1.seq,c1.fname,c1.lname);
         FETCH c1.seq INTO userjob;
    FOR c1rec IN c2 LOOP
    IF (c1rec.seq=c1.seq and c1rec.q1='why') THEN
    insert into t3 values(c1rec.q1,c1rec.a1);
    elsif (c1rec.seq=c1.seq and c1rec.q1='what') then
    insert into t3 values(c1rec.q2,c1rec.a2);
    elsif (c1rec.seq=c1.seq and c1rec.q1='when') then
    insert into t3 values(c1rec.q3,c1rec.a3);
    elsif (c1rec.seq=c1.seq and c1rec.q1='where') then
    insert into t3 values(c1rec.q4,c1rec.a4);
         END IF;
         END LOOP;
         END;
    /

    You should always fetch a cursor before using it's values. All columns in the select should be fetched into variables or a record-variable. You can't refer to the cursor-columns values with c1.seq etc.
    r1 c1%rowtype;
    l_found boolean;
    BEGIN
    OPEN c1;
    FETCH c1 INTO r1;
    insert into t3 values(r1.seq,r1.fname,r1.lname);
    l_found := c1%found;
    close c1;
    if l_found
    then
    It is also better to close the cursor and check if the select resulted in a row. With this code you will only retrieve one row even if the select will result in multiple rows.
    But I agree with all the others that this can probably be done more efficiently with one SQL statement.

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

  • Update SAME column name in two tables from ONE query

    Dear All Seniors
    Please tell me is it possible to update a same column name in two tables.
    I have two tables in same schema
    (1)table name
    pem.igp_parent
    column name
    igp_no.
    igp_type
    (2)table name
    pem.igp_child
    column name
    igp_no.
    igp_type
    i want to update igp_no column in one query please tell me how it would be possible.
    thanks
    yassen

    You want to update the data from what to what? Where is the new data coming from?
    If you are trying to put the same data in two different tables, that strongly implies that you have a normalization problem that needs to be addressed.
    Why do you want a single query rather than updating each table in turn? Can you join the two target tables to produce a key-preserved view?
    Justin

  • How can update two rows in one query?

    How can update two rows in one query?
    Edited by: OracleM on May 4, 2009 12:16 AM

    What do you mean with "two rows"? May be two columns??
    If the where clause of UPDATE query matches two rows, then it will update two rows. If you want to update two columns, then add column names to your query
    UPDATE your_table SET col1=value1, col2=value2 WHERE your_where_clause- - - - - - - - - - - - - - - - - - - - -
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • 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

  • Collapsing two tables into one table or one queue

    When you have data that exists in 2 tables A and B and B is essentially a child of A if you want to process these records such that you see all A's before their assoociated B how can you use either Streams or AQ to collapse these two tables into one? The data exists at it's source in database tables it will be replicated to another location and at that location I want to keep the data as it exists at the source but also process it in the ordered fashion I described above. My thinking is to publish the data to one queue but the challenge is to ensure that all A's are put on the queue before their B is. I don't just want a priority queue whereby all A's are processed before B's because if that happens B's will never be processed. but I simply want to avoid reading a B off the queue before I've read it's A.

    No version number and no clarity of what you are trying to accomplish.
    Without knowing that the problem is a nail ... I'd hardly be recommending using a hammer.

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

  • Update multi tables in one page

    I need to create a page that allow users to update ( no insert, no delete) 2 tables 1 view.
    home page users enter a record_no, then I pass the rec_no to p2 which has 3 regions. Each region points to one table\view respectively. All tables\view are linked by a same rec_no. Each region has a form on table with buttons: cancel,save.
    This works fine with only one region but When I start putting 2nd region,
    following issues arise
    1. data only display on most recently added region( form), it won't display on both regions
    2. when I click apply changes (save) on region 1, it erros on both regions that have not null columns. I think this is because it can't tell the difference on the button that I press.
    Is it possible to achieve this goal: update multiple tables in one page ? What is the best way to do it ?
    I don't want to use form with a report because it has extra page to go through.Ultimate goal is to make all regions Hide and show, so data won't clog whole screen if user has no need to see all at once. Is creating a view of these 3 tables\view the way to go ?
    Can you help ? My brain is fried now.
    Thanks.
    Tai

    Hello Tai,
    I understand your frustration. Sometimes, something that should seem easy turns out to be so difficult. In this case, what you can do is this:
    1. Get rid of the buttons in the second and third region. You can drive your updates all from only one set of buttons.
    2. Set a condition on your update button that it only do the update if all three regions data have been filled in - that is - the fields you need are NOT NULL.
    Sometimes, I have actually created a separate region called "Buttons" and that is all that resides there. When I have multiple regions on a screen that need input, I won't do any of the updates until all areas have been populated.
    As for hiding/displaying the various regions based on your user's need to see them, you can also set conditional display on the region so the user won't see them if they don't need to.. And/or use the hide/show region template.
    I hope this helps,
    Don.
    You can reward this reply by marking it as either Helpful or Correct :)

  • Can you have 2 iTunes accounts on one MAC Desktop

    I have a MAC Desktop which my husband and I share. We each have our own Itunes accounts, mine which is stored on an old Mac Book Pro with issues. In order for me to use the cloud I need to get my Itunes account onto the desktop. This laptop can not be updated to the icloud becasue of its problems. We can share the contacts and the calendar from the desktop, but we each have our own music. Can you have 2 itunes accounts on one desktop?

    Yes. Use separate Mac OS X user accounts, or launch iTunes with the Option key held down as needed.
    (88868)

  • Using table comparison transform can you point to multiple tables as target

    Using table comparison transform can you point to multiple tables as target tables?
    Thank you very much for the helpful info.

    If you want to feed the output to multiple tables, you can do so, but you have to be cautious enough on which table to be used as a comparison table in this case. The comparison table provided inside Table Comparison will be compared against the input data set for generating opcodes (Insert / Update / Delete) to input rows.

  • Saving data into two tables "in one transaction"

    Hello everybody!
    My scenario is the following: SAP PI receives message containing some data (header and MULTIPLE details data in one message) and has to transfere this data to a database.
    In the database there are two tables for storing the data contained in the message: one for HEADER data and one for DETAILS data. I need to save all the data (header and MULTIPLE details data) into these two tables "in one transaction" and roll back saving of HEADER data and DETAILS data if saving of some DETAILS data has failed.
    I am going to use receiver JDBC adapter for this purpose.
    My questions are:
    1. How can I save all the data "in one transaction"? Will it work if I transform the source message into the target message which looks something like this?
    <root>
      <StatementName1>
        <dbTableName action=u201CUPDATE_INSERTu201D>
        <table>HEADER_table</table>
        <access>
        <col1>val1</col1>
        <col2>val2</col2>
        </access>
        <key1>
        <col1>val1</col1>
        </key1>
        </dbTableName>
      </StatementName1>
      <StatementName2>
        <dbTableName action=u201CUPDATE_INSERTu201D>
        <table>DETAILS_table</table>
        <access>
        <col1>val1</col1>
        <col2>val3</col2>
        </access>
        <key1>
        <col1>val1</col1>
        </key1>
        </dbTableName>
      </StatementName2>
      <StatementName3>
        <dbTableName action=u201CUPDATE_INSERTu201D>
        <table>DETAILS_table</table>
        <access>
        <col1>val1</col1>
        <col2>val4</col2>
        </access>
        <key1>
        <col1>val1</col1>
        </key1>
        </dbTableName>
      </StatementName3>
    </root>
    2. How to roll back saving of HEADER data in the case of saving of DETAILS data has failed?
    3. What will be the response structure returned by database look like in the case of success?
    Thanks,
    Vika

    I guess the response in my case will be something as following?
    <response>
    <Statement1_response>
    <row>
    <update_count>1</update_count>
    <insert_count>0</insert_count>
    </row>
    </Statement1_response>
    <Statement2_response>
    <row>
    <update_count>0</update_count>
    <insert_count>1</insert_count>
    </row>
    <row>
    <update_count>0</update_count>
    <insert_count>1</insert_count>
    </row>
    </Statement2_response>
    </response>
    Vika

  • Delete from two tables in one statement

    Hi,
    Is there a way to delete from two tables in one statement?
    Actually I have two tables:
    1. Base table (id, name, age)
    2. Person table (id, city, street)
    The id in both tables is identical.
    I would like to delete using something like a join:
    Delete from base, person where id=2;
    Thanks
    dyahav

    Hi,
    If you want to delete records both at a time them your table must use ON DELETE CASCADE. See the below example.
    CREATE TABLE supplier
    ( supplier_id numeric(10) not null,
    supplier_name varchar2(50) not null,
    contact_name varchar2(50),
    CONSTRAINT supplier_pk PRIMARY KEY (supplier_id)
    CREATE TABLE products
    ( product_id numeric(10) not null,
    supplier_id numeric(10) not null,
    CONSTRAINT fk_supplier
    FOREIGN KEY (supplier_id)
    REFERENCES supplier(supplier_id)
    ON DELETE CASCADE
    In this example, we've created a primary key on the supplier table called supplier_pk. It consists of only one field - the supplier_id field. Then we've created a foreign key called fk_supplier on the products table that references the supplier table based on the supplier_id field.
    Because of the cascade delete, when a record in the supplier table is deleted, all records in the products table will also be deleted that have the same supplier_id value.
    Thank you.

Maybe you are looking for

  • How do I create a PDF with a resolution of 300 or 600? Where is the control in X Pro?

    How do I create a PDF with a resolution of 300 or 600? Where is the control in X Pro?

  • Canon 350d cr2 supported?

    Hi all. I have Aperture 1.5 currently shipping but noticed something odd in the 'supported camera raw' page. Within it has an asterix next to Canon XT that's supposed to meaning 'providing optimized support' but not the 350d. Anyone know exactly what

  • Default shell login not taking effect.

    Hello all. MBP running 10.5.1 as a portable user on a 10.5.1 Server fresh build. A user's default shell login was originally set to /bin/bash. I then changed it to "none" and now can not change it back to "/bin/bash" or any other shell. Even when I c

  • Open script in illustrator from Java servlet

    This may be better suited to a java forum, but I figured someone may have done it here. I need to tell illustrator to run a script from my java servlet. any ideas? thanks. i can't just open the js file with illustrator, as it treats it as text, i nee

  • OAK3 error message - Specifications for the mean value methods incorrectly

    Hello experts, After golive of sap ECC system of our client, when the auditors check the consistency of depreciaion areas in transaction OAK3, the error message is appearing under the depreciation area 01 as "Specifications for the mean value methods