Update of several columns on multiple tables

Hello

I try to update several columns on two different tables, and I would like to know how to proceed in a SQL statement.

I have the data I want to update in this SQL statement...

#####################################

Select srv. X_SERVICING_DEALER as 'The merchant name', -(want to update this column)

SRV. X_SERVICING_SITE as ' dealer # ', -(want to update this column)

dlrx. ATTRIB_50 'Région',--(tiens à mettre à jour cette colonne)

dlrx. ATTRIB_49 as 'District', -(want to update this column)

DLR.x_zone_cd as 'Zone'-(want to update this column)

Of

s_srv_req srv,

s_org_ext dlr,

s_org_ext_x dlrx

where dlr.row_id = srv.pr_con_org_id

and dlr.row_id = dlrx. par_row_id

and srv.row_id = 1-1RSEXAV';

#####################################

Any guidance would be appreciated.  Thanks in advance.

Chris

> I'm trying to update several columns on two different tables, and I would like to know how to proceed in a SQL statement.

You can not.  Only one table can be updated at the same time.

Tags: Database

Similar Questions

  • Update using several terms from multiple tables

    Hello

    I'm quite new to PL/SQL.

    I need to update a record in a table with several conditions in which the clause of several tables.

    On the internet I found something like

    Update < table >
    Set < column > = < value >
    < Table >
    Join them < table >
    on < condition >
    Where < condition >
    And < another condition >

    Now, I have:

    Update outbound_order
    Set outbound_order_sorting_code = "A".
    to orderref o, oo outbound_order
    where oo.ordernumber = o.ordernumber
    and o.delivery_status = 'c ';

    It gives ORA00933 of Pl/SQL to->

    I can't use more than one table in update?

    Kind regards

    Chi Wai
    update outbound_order o
    set outbound_order_sorting_code = 'A'
    where exists(select 1 from orderref oo
                  where oo.ordernumber = o.ordernumber)
    and delivery_status = 'c';
    
  • Update multiple columns from multiple tables in a single UPDATE request

    Hello

    I'm trying to figure if I'm heading in the right direction.

    I want to update multiple columns from multiple tables in a single UPDATE request. Also, I would like to update multiple columns in a table from the tables.

    Scenario 1

    UPDATE Table2, Table 3
    SET T2.Column1 = T1.Column1 
    ,T2.Column2 = T1.Column2
    ,T3.Column2 = T1.Column2
    FROM Table1 T1, Table2 T2, Table3 T3
    WHERE T1.id = T2.id
    and T1.id = T3.id
    
    

    Scenario 2

    UPDATE Table3
    SET T3.Column1 = T1.Column1 
    T3.Column2 = T1.Column2
    ,T3.Column3 = T2.Column3
    ,T3.Column4 = T2.Column4
    FROM Table1 T1, Table2 T2, Table3 T3
    WHERE T3.id = T1.id
    and T3.id = T2.id
    
    

    Hello

    For scenario 1, you must write separate instructions UPDATE table2 and table3.

    To guard against someone else change one of these tables while you act so you can copy all relevant data in a global temporary table and update this global temporary table table3.

    ENGAGE only when two tables have been changed.

    You can write a procedure or an INSTEAD OF trigger to do all this.

    For scenario 2, you can reference many tables that you need when new table3.  It might be more efficient and simpler to use the MERGER rather than UPDATED.  For example:

    MERGE INTO table3 dst

    WITH THE HELP OF)

    SELECT t1.id

    t1.column1

    t1.column2

    t2.column3

    t2.column4

    FROM table1 t1

    JOIN table2 t2 ON t1.id = t2.id

    )             src

    WE (dst.id = src_id

    WHEN MATCHED THEN UPDATE

    SET dst.column1 = src.column1

    dst.column2 = src.column2,

    dst.column3 = src.column3,

    dst.column4 = src.column4,

    ;

  • access to update only one column in the table?

    Hi all

    My need is to grant access to update only one column c1 in table t1.
    I guess I should use view, could you please give me some examples? Maybe other ideas?

    Hello

    You can grant privileges on individual columns.

    GRANT   UPDATE (c1)
    ON      t1
    TO      grantee_name;
    

    Look in the manual of the SQL GRANT language. Annoyingly, in editions recent manual, GRANT is not indexed, but it is in alphabetical order with all other instructions:
    http://docs.Oracle.com/CD/E11882_01/server.112/e26088/statements_9013.htm#i2155015

  • Repetitive copy of columns from multiple tables

    I need to add some "columns of audit" as created date/time line, time line last updated, etc. to a large number of tables.

    If I was using ERwin, I would generally create these columns in a table "scratch" in the model, with comments, appropriate data types, etc. and I could then copy (ctrl - drag / drop) to other tables as needed.

    Is there a way to accomplish a similar copy with SQL Developer Data Modeling? I don't want to open all the tables, go to the list of columns, click Add for each column, comment, etc.

    Thank you
    Mike

    Hi Mike,.

    You can do that - you can copy columns in the table editor or in the browser (in the latter case, they can belong to more than one table) and use paste functionality into the context menu table or in the table editor - you can select more than one table, use the dough. There are also two scripts of transformation to come with the tool ("Table model"), which you can customize to do less manual work.

    Philippe

  • Try to update the new column in the TABLE one by reading another table

    I had to add another column to a table and for updating this column, I need to read two other paintings, according to the REF_TYPE_CD.




    Update CUST_RQST_DROP c
    Set crd_mktr_no = (select mka_mktr_no from marketer_account
    where mka_acct_no = c.crd_ref_no
    and c.entry_dt between mka_eff_dt and mka_exp_dt
    and c.crd_ref_type_cd = 'A');

    Update CUST_RQST_DROP c
    Set crd_mktr_no = (select aeq_mktr_no from acct_enroll_que
    where aeq_work_q_no = c.crd_ref_no
    and c.crd_ref_type_cd = 'P');


    I don't know how to combine in a single query.

    Any suggestions would be greatly appreciated

    Well, I still had to build all of the DDL and DML statements me:(dans l'avenir, je recommanderais ajouter ceci dans votre post, vous aurez BEAUCOUP plus de gens prêts à aider si vous le faites.) Just a suggestion for your benefit.

    It should work assuming you have a relationship with each other between tablea and b and c... AND you never have more than one row in the child table (b or c to a given value in one).

    create table tablea
    (
    account_no      number,
    entry_dt     date,
    ref_type     varchar2(1),
    refno          number,
    mkt_no          number
    );
    
    create table tableb
    (
    id               number,
    account_no      number,
    mkt_no          number
    );
    
    create table tablec
    (
    id               number,
    account_no      number,
    mkt_no          number,
    eff_dt          date,
    exp_dt          date
    );
    
    insert into tablea values (123, to_date('04/01/2010','mm/dd/yyyy'), 'P', 9983, null);
    insert into tablea values (124, to_date('04/02/2010','mm/dd/yyyy'), 'A', 3452, null);
    insert into tablea values (125, to_date('04/02/2010','mm/dd/yyyy'), 'P', 9984, null);
    
    insert into tableb values (9983, 123, 10001);
    insert into tableb values (9984, 125, 11232);
    
    insert into tablec values (3452, 124, 10333, to_date('01/01/2010','mm/dd/yyyy'), to_date('05/19/2010','mm/dd/yyyy') );
    
    ME_XE?Update TableA a
    set mkt_no =
    (
         select mkt_no from tableb b where b.account_no = a.account_no and a.ref_type = 'P'
         union all
         select mkt_no from tablec c where c.account_no = a.account_no and a.ref_type = 'A' and a.entry_dt between c.eff_dt and c.exp_dt
    )
    where mkt_no is null;
    
    3 rows updated.
    
    Elapsed: 00:00:00.12
    ME_XE?select * from tablea;
    
            ACCOUNT_NO ENTRY_DT             R              REFNO             MKT_NO
    ------------------ -------------------- - ------------------ ------------------
                   123 01-APR-2010 12 00:00 P               9983              10001
                   124 02-APR-2010 12 00:00 A               3452              10333
                   125 02-APR-2010 12 00:00 P               9984              11232
    
    3 rows selected.
    
    Elapsed: 00:00:00.15
    
  • Adding a single column to multiple tables

    I have to add a column to 664 tables.

    I can copy the column of the table, in that it was originally created.
    Is it possible to paste the column in all the remaining tables?
    It doesn' t work by selecting all tables in the design ('Ctrl + ", do a right click 'paste').
    He works if I click on each individual table ('Ctrl', left click) but I don't want to have to click on each 664 tables.

    Thank you
    NIC

    Watch demo in the: [use a Transformation Script | http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldevdm/r30/dm30desrule/dm30desrule.htm#t4]
    so easy :).
    I think, model table is the solution for you :D

  • update of several columns of values in another table

    Hello

    I have two tables in a database of 11 GR 2 that contain similar data. There is no FK relationship between the two tables, and for now, I need the data in MASTER to match what is in the SECONDARY. Table data types are the same with the same length.

    Table 1 is called MASTER and columns are:
    MTID
    ADDRESS1
    ADDRESS2
    CITY

    Table 2 is called SECONDARY and columns are:
    SDID
    ADDRESS1
    ADDRESS2
    CITY

    MID and SID are the same on both, but the rest of the columns may be the same or in some cases are different.

    I ran the following query that lets me know there are 20 k odd rows that have different data in these lines (I'm not at work at the mo so do not have the exact query I ran or table column names, but it's close enough).
    select
    m.address1 as maddress1,
    s.address1 as saddress1,
    m.address2 as maddress2,
    s.address2 as saddress2,
    m.city as mcity,
    s.city as scity
    from master m, secondary s
    where m.mtid = s.sdid
    and m.address1 != s.address1
    or m.address2 != s.address2
    or m.city != s.city
    /
    I need to update the rows in the master of secondary school where these values are different. I tried a few different queries updated with no luck.

    I want to do something like
    update m.address1
    set m.address1=s.address1
    where m.address1 != s.address1
    and m.mtid = s.stid;
    But I want to update columns address1 and address2, city of master.

    Any ideas on how I can do this? After you run the update results of my select query should return no rows.

    Thanks in advance and I hope that the question made sense.

    1008991 wrote:
    I got a similar error as well:

    update master m
    set (sm_user_addr_1, sm_user_addr_2, sm_user_city, sm_user_postal_cde)
    = (select sm_user_addr_1, sm_user_addr_2, sm_user_city, sm_user_postal_cde
    from secondary s
    where s.sd_key = m.sm_key
    )
    where exists (
    select 1 from secondary s
    where s.sd_key = m.sm_key
    and (s.sm_user_addr_1     != m.sm_user_addr_1 or
    s.sm_user_addr_2     != m.sm_user_addr_2 or
    s.sm_user_city       != m.sm_user_city   or
              s.sm_user_postal_cde != m.sm_user_postal_cde));
    
    ERROR at line 3:
    ORA-01427: single-row subquery returns more than one row
    

    It simply means that you have several lines with the same sd_key for a given sm_key.
    Is that you have secondaries for one master. You must choose only one line
    If you need additional terms in your where clause

    select sm_user_addr_1, sm_user_addr_2, sm_user_city, sm_user_postal_cde
               from secondary s
             where s.sd_key = m.sm_key
    
  • Select cursor for update: multiple columns of different tables

    Hello

    I have two tables test1 and test2. I want to udpate the column (DEPT_DSCR) from the TEST1 and TEST2 using select for update and current tables of the... with the cursor.

    I have a code drafted as follows:
    DECLARE
    v_mydept1 TEST1. TYPE % DEPT_CD;
    v_mydept2 TEST2. TYPE % DEPT_CD;
    CURSOR C1 IS SELECT TEST1. DEPT_CD, TEST2. DEPT_CD OF TEST1, TEST2 WHERE TEST1. DEPT_CD = TEST2. DEPT_CD AND TEST1. DEPT_CD IS 'AA' FOR THE UPDATE OF TEST1. DEPT_DSCR, TEST2. DEPT_DSCR;
    BEGIN
    OPEN C1;
    LOOP
    FETCH C1 INTO v_mydept1, v_mydept2;
    WHEN EXIT C1% NOTFOUND;
    UPDATE TEST1 SET DEPT_DSCR IS "PLSQL1" WHERE CURRENT OF C1;.
    SETTING A DAY TEST2 SET DEPT_DSCR = 'PLSQL2' WHERE CURRENT OF C1.
    END LOOP;
    COMMIT;
    END;

    The code above when it is run, declares that it runs successfully. But it does not update the columns you want [DEPT_DSCR].

    It works only when we want to update one or more columns of the same table... i. e by providing these columns after ' to UPDATE THE.
    I don't know what exactly is the problem when you want to update several columns of different tables.

    Can someone help me on this?

    user12944938 wrote:
    But it's more the notion of compensation and understanding.

    See the link below:
    http://download.Oracle.com/docs/CD/B10501_01/AppDev.920/a97269/pc_06sql.htm

    See the section RESTRICTION in the link above.

    Twinkle

  • Help to extract data Clob to a column in a table that has several lines in a table

    Help to extract data Clob to a column in a table that has several lines in a table

    It works for only the first line

    CREATE or REPLACE DIRECTORY XMLDIR AS ' / orabackups';

    Grant read, write on DIRECTORY XMLDIR to the public;

    () dbms_xslprocessor.clob2file

    beef in CLOB,

    XMLDIR IN VARCHAR2,

    "testfile2.txt" IN VARCHAR2);

    DECLARE

    buf CLOB.

    BEGIN

    SELECT H15_DOC

    IN buf

    OF H15TEST. H15_STAGE

    where rownum = 1;

    dbms_xslprocessor.clob2file (buf, 'XMLDIR', 'testfile2.txt');

    END;

    /

    -This error code

    CREATE or REPLACE DIRECTORY XMLDIR AS ' / orabackups';

    Grant read, write on DIRECTORY XMLDIR to the public;

    () dbms_xslprocessor.clob2file

    XData in CLOB,

    XMLDIR IN VARCHAR2,

    "testfile2.txt" IN VARCHAR2,

    CSID in NUMBER: = 0);

    DECLARE

    CURSOR xmlmycur IS SELECT H15_DOC

    OF H15TEST. H15_STAGE

    where rownum = 102140;

    l_clob CLOB.

    XData CLOB.

    BEGIN

    DBMS_LOB.CREATETEMPORARY (l_clob, true);

    DBMS_LOB.CREATETEMPORARY (xdata, true);

    OPEN xmlmycur.

    LOOP

    SEEK xmlmycur INTO xdata;

    dbms_xslprocessor.clob2file (xdata, 'XMLDIR', 'testfile2.txt');

    EXIT WHEN xmlmycur % notfound;

    END LOOP;

    CLOSE Xmlmycur;

    END;

    /

    ORA-21560: 3 argument is null, invalid or out of range

    ORA-06512: at "SYS." DBMS_LOB", line 991

    ORA-06512: at "XDB". DBMS_XSLPROCESSOR', line 324

    ORA-06512: at line 15 level

    FYI, it seems that the file being created will exceed 5 gig

    Yes, it is a known issue with DBMS_XSLPROCESSOR.clob2file with big files.

    Here is a slightly modified version of the code that I posted earlier, fixing WRITE_ERROR except:

    DECLARE

    v_file utl_file.file_type;

    -write a unique to clob

    procedure write_clob (p_content in clob) is

    v_buffer varchar2 (32767).

    V_POSITION pls_integer: = 1;

    v_amount pls_integer: = 32767;

    Start

    loop

    Start

    DBMS_LOB. Read (p_content, v_amount, v_position, v_buffer);

    exception

    When no_data_found then exit;

    end;

    UTL_FILE.put_raw (v_file, utl_raw.cast_to_raw (v_buffer), true);

    V_POSITION: = v_position + v_amount;

    end loop;

    end;

    BEGIN

    -Open the file

    v_file: = utl_file.fopen ('TEST_DIR', 'testfile2.txt', 'wb', 32767);

    -loops through the lines

    for r in)

    Select h15_doc

    of h15test.h15_stage

    )

    loop

    write_clob (r.h15_doc);

    end loop;

    UTL_FILE.fclose (v_file);

    END;

    /

  • need help to trigger to update the change of columns of a table

    Hi all
    I need help in the manufacture of change update trigger in the columns from one table to another table.
    For example, table (col1 col 2 col 3 col 4 col 5 samplea
    .. .Col 20

    Now if I do any change in one of the data column must be changed to
    sample_copya... table that contains duplicate column

    So for this I thought to create a trigger with the following logic



    If updating (col1) then
    Update sample_copya set col1: =: new.col1 where n ° 1 =: new.no1;
    Otherwise, if the update (col2) then
    Update sample_copya set col2: =: new.col2 where n ° 1 =: new.no1;
    Otherwise, if the update (col3) then
    Update sample_copya set col3: =: new.col3 where n ° 1 =: new.no1;

    end if;
    But how doi handle if all columns are changed or say 2 columns record the number of columns is more than 20...
    I would like to know if there is a simpler method to achieve...
    Thank you

    susf wrote:
    Hi all
    I need help in the manufacture of change update trigger in the columns from one table to another table.
    For example, table (col1 col 2 col 3 col 4 col 5 samplea
    .. .Col 20

    Now if I do any change in one of the data column must be changed to
    sample_copya... table that contains duplicate column

    So for this I thought to create a trigger with the following logic

    If updating (col1) then
    Update sample_copya set col1: =: new.col1 where n ° 1 =: new.no1;
    Otherwise, if the update (col2) then
    Update sample_copya set col2: =: new.col2 where n ° 1 =: new.no1;
    Otherwise, if the update (col3) then
    Update sample_copya set col3: =: new.col3 where n ° 1 =: new.no1;

    end if;
    But how doi handle if all columns are changed or say 2 columns record the number of columns is more than 20...
    I would like to know if there is a simpler method to achieve...
    Thank you

    What is the purpose of this trigger?
    How can you be sure that ' where n ° 1 =: new.no1 "is true?
    How does line in the SAMPLE_COPYA table at the start?
    only the last modified value will lie in SAMPLE_COPYA than the previous values is written more

  • How to update the table by using the value of a column in a table field

    Hi all
    use APEX4.1,
    I have a tabular presentation based on the HOLIDAY table, it contains the following fields,
    Leave_id
    Employee_name
    No_of_days
    Status
    Here's the column LOV updateable status.
    Lov includes 2 values IE APPROVE and REJECT

    and I have another Table called LEAVE_HISTORY, it contains the following fields.
    Emp_name
    status
    Here whenever the ststus is updated (click the button SUBMIT) in tabular form should also be updated in the LEAVE_HISTORY of the SITUATION of the table column.

    I tried the following in the process of "WE SUBMIT AFTER CALCULATIONS AND VALIDATIONS,"
    begin
    update LEAVE_HISTORY set status= status where upper(employee_name)=upper(emp_name);
    end;
    but it is not kept up-to-date,
    When we updated through forms we can use something like this,
    update LEAVE_HISTORY set status= :P200_status where upper(employee_name)=upper(:P_200_emp_name);  <----here we are referring page item i.e (:P_200_emp_name)
    as the code above, how to run the columns in a table?
    Thank you.

    Hi Gurujothi,

    Try this,

    begin
    update LEAVE_HISTORY
    set status= :STATUS
    where upper(Emp_name)=upper(:EMPLOYEE_NAME);
    end;
    

    Brgds,
    Max

  • How update the column in the table based on the value selected in apex4.1

    Hi all
    I have the following tables,
    leave_type table,it has the following fields,
    1.emp_name,
    2.sick
    3.casual
    and it has the values as follows,
    emp_name                  sick             casual
    guru                           10                10
    mishra                         10                10
    leave_master table and it includes the following fields
    1.emp_name,
    2.leave_type
    3.no_of_days
    I have the form based on the table "leave_master"
    Here, the leave_type has the LOV which includes.
    sick and casual.

    When the form is filled out and clicked on the button submit,
    I need to update the column leave_type in table leave_type,
    for example,.
    if 
    emp_name:guru
    leave_type:sick
    no_of_days:3
    then I want to update the leave_type column,
    sick sick = - no_of_days for the 'guru' of name
    That is to say, ill = 10-3 = 7

    then the leave_type of the table must be,
    emp_name                       sick             casual
    guru                                 7                10
    mishra                              10               10
    someone can such me what code or method I can use?
    Thank you.

    Published by: Gurujothi on May 24, 2012 21:54

    Published by: Gurujothi on May 24, 2012 21:54

    Try something like this...

    BEGIN
    IF: PXX_LEAVE_TYPE = "Sick" THEN
    UPDATE LEAVE_TYPE
    THE PATIENT VALUE = SICK -: PXX_NO_OF_DAYS
    WHERE EMP_NAME =: PXX_EMP_NAME;
    ON THE OTHER
    UPDATE LEAVE_TYPE
    DEFINE CASUAL = CASUAL -: PXX_NO_OF_DAYS
    WHERE EMP_NAME =: PXX_EMP_NAME;
    END IF;
    COMMIT;
    END;

  • Cannot update the END_DATE_ACTIVE column in the HZ_CODE_ASSIGNMENTS Table through the API

    Hello

    I'm not able to update the column END_DATE_ACTIVE HZ_CODE_ASSIGNMENTS Table through the API: hz_classification_v2pub.update_code_assignment.
    After running with all the facings that he managed, but it is not properly updated the end_date_active to the date given as parameters when executing the API defines it rather end_date_active to null.

    Please help.

    Thanks and greetings

    Salvation;

    What is your version of the EBS? If you are on r12.x you can hit bug. Please see:
    Unable to update HZ_CODE_ASSIGNMENTS end_date_active with January 1, 2012 [1166367.1 ID]

    Respect of
    HELIOS

  • need a script to create multiple tables as the other columns in tables

    I need script to create multiple tables as the other columns of tables respectively.

    lets consider I want to create tables from table1... table99 like tablex1... .tablex99 columns (without data) respectively (i.e table1 as tablex1, table99 as tablex99).
    declare
    
    cursor c is select object_name from all_objects where object_type='TABLE';
    
    begin
    
    for i in c loop
    
    execute immediate 'create table '||i.object_name||'_x as select * from '||i.object_name||' where 1=2';
    
    end loop;
    
    end;
    
    use can use this and put your user names accordingly.
    If you get any error please post the error.
    

Maybe you are looking for

  • Using a second monitor with PC HP TouchSmart 320

    I just bought a PC HP TouchSmart 320.  I work from home and need to use 2 monitors.  I have a Vizio HD TV and I was wondering if I could use it as my second monitor

  • BIOS password problems

    No idea how but among the small treasure in this school was able to remove ALL the programs installed on this laptop AND change the BIOS password so I can't rebuild it.  I hate this school.  In any case... HP laptop computer 635 Disabled system [6688

  • Help: More sensitive to the pinch and zoom

    I recently bought Acer, Aspire V3-572PG (Aspire |) (V), with 8.1 Windows installed, it has a screen pinch and zoom that drives me crazy.  The screen automatically reached the size of an elephant and or reduced to a postage stamp all the few minutes t

  • Windows Media Player cannot synchronize with the Sansa player. Sync button frozen

    OT: Button of Windows media player is frozen I have a sansa and I tried to synchronize new songs from Windows Media player but the sync button is frozen, it wont let me press the key.

  • List drop down error

    Hello I create a drop-down list of cities. but when I select an operation occurs according to the first entry in the list I want to select a city from the drop-down list and click the next button to send the city selected to the next screen Please ta