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';

Tags: Database

Similar Questions

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

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

    ;

  • To create an interactive report in the apex by selecting from multiple tables

    Hi, I am creating an interactive report by selecting from multiple tables.

    SELECT w.FIRST_NAME as name, w.SURNAME as name, i.ROAD Road, i.DATE_OF_INC as DATE_OF_INC, S.STATEMENT as a STATEMENT OF Declaration

    JOIN THE

    WITNESS w

    ON w.witness_id = s.FK1_WITNESS_ID

    JOIN THE

    Incident I have

    WE

    i.incident_no = w.FK1_INCIDENT_NO

    JOIN THE

    user_station ps

    ON ps.station_id = i.nearest_station_id

    JOIN THE

    the user in.

    WE

    in. STATION_ID = ps.station_id

    WHERE po.officer_id = 1

    by I continue to encounter this error "the report query requires a unique key to identify each row. The supplied key cannot be used for this query. Please change the report attributes to define a unique key column. "ORA-01445: cannot select ROWID from where sample, a join without key preserved table view '

    So I googled around and found that in the attibutres tables report, I need to change the "LINK" COLUMN so first, I changed "Link to custom target", but the report is so I changed it to "Exclude link Clolumn" again, the report didn't report and I STILL got a blank page with only the tabs.

    I wonder you can not create a report by selecting from multiple tables?

    If you can please I need your help.

    Thank you

    You can, but in this case, it might be easier to build your report tables that are joined Oracle views and then build your report out of the newly built sight...

    Or wrap a selection around your selection with joins, and then make the where clause on the external selection...

    Thank you

    Tony Miller
    Software LuvMuffin
    Ruckersville, WILL

  • Use with need to collect in bulk to insert records from multiple tables

    Hello

    I plsql record type with several tables with multiple columns. so when I used bulk collect with education for ALL. I want to insert records in multiple tables.

    Please give me suggestions.

    ForAll is designed to be used with a single DML statement, which may include dynamic SQL statements. However, I do not know what advantage this will give you your list iteration save several times, one for each table - especially since there is an air show with SQL dynamic.

    Example 1 (dynamic SQL):

    begin

      ...

      forall i in vRecList.First..vRecList.Last
        execute immediate '
        begin
          insert into Table1 (Col1, Col2, Col3) values (:1, :2, :3);
          insert into Table2 (Col1, Col2, Col3) values (:1, :2, :3);
        end;' using vRecList(i).Col1, vRecList(i).Col2, vRecList(i).Col3;
    end;

    Another approach that I should work (but not tested) is using to insert all the Scriptures and based record inserts, but you need to try on your version of Oracle forall has changed between the versions.  In this case vRecList must be compatible with the Table % ROWTYPE and Table2% ROWTYPE type.


    Example 2 (insert all):

    begin

      ...

      forall i in vRecList.First..vRecList.Last

        insert all

          into Table1 values vRecList(i)
          into Table2 values vRecList(i)
        select 1 from dual;

    end;

  • Delete query to delete records from multiple tables

    All,

    I need a delete query that will delete the records from the tables. Please see the structure of the table & below
    CREATE TABLE TEMP1 (ID NUMBER(10),NAME VARCHAR2(40),CLASS VARCHAR2(40),COLLEGE VARCHAR2(40));
    CREATE TABLE TEMP2 (ID NUMBER(10),CITY VARCHAR2(40),STATE(40));
    
    INSERT INTO TEMP1 (ID, NAME,CLASS,COLLEGE) VALUES (1000,'SAM','CS','UNIV_1');
    INSERT INTO TEMP1 (ID, NAME,CLASS,COLLEGE) VALUES (2000,'RIO','CS','UNIV_1');
    INSERT INTO TEMP1 (ID, NAME,CLASS,COLLEGE) VALUES (3000,'CHRIS','CS','UNIV_1');
    INSERT INTO TEMP1 (ID, NAME,CLASS,COLLEGE) VALUES (4000,'ALEX','CS','UNIV_1');
    
    INSERT INTO TEMP2 (ID, CITY,STATE) VALUES (1000,'Auburn','NY');
    INSERT INTO TEMP2 (ID, CITY,STATE) VALUES (2000,'Ithaca','NY');
    INSERT INTO TEMP2 (ID, CITY,STATE) VALUES (3000,'Mount Vernon','NY');
    INSERT INTO TEMP2 (ID, CITY,STATE) VALUES (4000,'Port Jervis','NY');
    Now, I need to delete the records in these tables where the ID is '2000' by using a single delete query. Is this possible? This may be a newbie question. Help, please.

    "using a single request deletion. Is this possible?

    Nope.
    You can insert into multiple tables by using a single query, INSERT ALL job, but you cannot delete more than one table using a single query.

  • Storage from multiple tables in one MySQL query

    So I would like, with a single MySQL query, extract data from a table (say 15 rows of data) and then extract data from another table (lets say another 15 ranks) and who joined the first, so that I can view and paginate a single list (of 30 rows now).  I don't think that a join is what I'm looking for, because I want the second list should be annexed to the first and not mixed in.  I would just use different queries, but I already have the paging function implemented for a single set of records, and implementation with two (where the second begins when the first leaves) seems daunting. However, if you have any tips on one, they would really help.

    Thank you

    You need to use a UNION to join the two select statements. The number of columns and the data types of each selection must match.

  • Loading data from multiple tables in essbase using ODI

    Hello

    We have a scenario where the data comes from more than one table. I would like to know how ODI will load the data for the right combination of members

    Hello

    Consider each data table has a field that corresponds to the other table. You can simply drag the source interface data warehouses and create a join between the tables.

    See you soon

    John
    http://John-Goodwin.blogspot.com/

  • How can I search and return several items from the table quickly (like Matlab find)?

    Hi, I'm a pretty experienced Labview programmer, and I've always wondered if there is a way to quickly search for pictures on several items that meet the selection criteria, equivalent to the Matlab find command.  While my inability to do in Labview has always annoyed me, I now have an application that requires this capability and I need to find a solution.

    Is the fastest way I've found to do this in labview to perform comparisons on the data vectors, then use the Boolean value that results from vector to analyze the table using a loop and shift registers.  I enclose an extract vi a analysis comparative vi to one of the simple searches that I need to do.  On my laptop, this research takes about 600 ms.  In comparison, the equivalent in Matlab:

    newArray=oldArray(find(oldArray(:,4)./oldArray(:,2)>1.5),;

    runs in about 1.2ms.  So, the way I am doing this in Labview is only 400 times slower

    Needless to say, I need to make these types of research many times, and these additional 599 ms start to add up pretty quickly!

    Thanks for your help,

    Aaron

    Hi Aaron,

    the slow part is probably "build group" of the node in the loop.

    Try this:

    Define an array the same size as the input data (or simply uses a copy of it) and the wire that to the shift register. Keep a counter of lines found in the loop. Use IndexArray and ReplaceArraySubset for the loop to move rows found at the beginning of the table (overwrite the 'bad' lines). After the loop simply ReshapeArray the number of found lines...

    Sorry, don't have LV (2009) on hand for editing your snippet.

  • A block in Oracle may contain data rows from multiple tables?

    Hi in my discussion with one of the DBA, a point came that is a block shouldn't have several tables lines...

    Is this true? I read in one of the OTN thread (I don't exactly remember the name of the thread) that a block can have data from several tables. If it does not, what is the table block directory mean?

    Please let know us your opinion.

    Thank you

    CSM

    Hi all

    See the last 12 c here (http://docs.oracle.com/cd/E16655_01/server.121/e17633/logical.htm#CNCPT004). They have explicitly mentioned the term 'CLUSTER' here.

    This confusion was caused by the incorrect documentation and they corrected it

    Thanks for everyone to share their points of view.

    CSM

  • 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

  • using a join of multiple tables to create queries

    Hello...

    I don't have a lot of work on the oracle...

    I have to create the query of tables...


    _ Of the STUDENT

    SNO (pk)
    SNAME
    deptId (FK)



    EVENT_

    eventId (PK)
    eventName
    deptId (FK)



    _ DEPT

    deptId (pk)
    deptName



    now I need list of students with events that can they participate...

    as

    sName event

    Tech John

    John headstart




    Pls answer me...

    Thanks in advance...

    Select sname, eventname
    Student event
    where student.deptid = event.deptid

  • How to use several adf 12 shape and insert the form data in to table during the click on "submit" button

    How to use several adf 12 shape and insert the form data in to table during the click on "submit" button. Can we use several form from adf or not?

    Make sure that you dragged the VO based EO.

    Also make sure that the VO attributes based EO Updatable property.

    The query according to VO is used only to add LOV to the column of the original VO ModelId.

    See you soon

    AJ

  • cannot find the table name of the multiple tables which has more columns.

    Hello

    I'm trying to find the NAME of the TABLE from multiple tables which has more columns. I can't count the number of columns in the table, but cannot find the name of the table that has larger columns in other tables.

    SELECT TABLE_NAME, COUNT (*) FROM THE USER_TAB_COLUMNS WHERE TABLE_NAME LIKE '% LOC' GROUP TABLE_NAME


    Thank you.

    in SQL, you can try this:

    var v_name varchar2(40)
    
    begin
       with
          subq1 as ( select table_name, count(*) as column_count from user_tab_columns where table_name like 'FIBER%'
                         group by table_name
                         order by count(*) desc )
       select table_name
         into :v_name
        from subq1
       where rownum = 1;
    end;
    

    To get the result:

    select :v_name from dual
    

    The clause "with" brings together all the tables and ordered them all first, by the greatest number of columns
    The final query uses the rownum restriction so that it takes the first name from the table of results of the subquery.

    The restriction of rownum also exactly guarantees a result each time so that it will work with the variable binding.

    RP

  • Select from another table, when the query returns no result

    Hello

    I have a question where I'm supposed to retrieve the address of an account id-based billing. However, the table of billing may not have an address. There is a table of addresses that always has an address for an account. If the billing address exists, it should be used, so I can't use the address table. Is it possible in a select statement to query to the billing address and if it does not exist, use the address table.

    SELECT * FROM accounts a, b billings WHERE a.accountid = b.accountid

    Any help will be greatly appreciated.

    Thank you.

    user10407139 wrote:
    Hello

    I have a question where I'm supposed to retrieve the address of an account id-based billing. However, the table of billing may not have an address. There is a table of addresses that always has an address for an account. If the billing address exists, it should be used, so I can't use the address table. Is it possible in a select statement to query to the billing address and if it does not exist, use the address table.

    SELECT * FROM accounts a, b billings WHERE a.accountid = b.accountid

    Any help will be greatly appreciated.

    I think you need to explain more clearly if

    -you only have a couple of "billing" columns which is empty and in this case, you want to use the columns from the table 'accounts '.

    - or you have a join with another table that doesn't return data, for example a foreign key "address_id" "billing" is zero and therefore the join to other tables 'address' will return all the data

    In the first case, you have already been provided with some examples here, how to use NVL or similar functions to achieve, even if the first post first evaluates the information of 'accounts' and if it is white using information from "billing". According to your description you need the other way around. The second post a subquery recursive useless in my opinion.

    In the latter case, you should probably use an "outer" join so that the data in your table "bills" are returned, even if the join to another table is not at all the lines.

    SELECT
    NVL(AD1.ADDRESS_ATTR1, AD2.ADDRESS_ATTR1) as ADDRESS_ATTR1,
    NVL(AD1.ADDRESS_ATTR2, AD2.ADDRESS_ATTR2) as ADDRESS_ATTR2,
    NVL(AD1.ADDRESS_STREET, AD2.ADDRESS_STREET) as ADDRESS_STREET,
    ...
    FROM accounts a
    INNER JOIN billings b
    ON a.accountid = b.accountid
    LEFT OUTER JOIN address ad1
    ON b.address_id = ad1.address_id
    INNER JOIN address ad2
    ON a.address_id = ad2.address_id;
    

    In this way you pick up the address stored in the "invoices" table, if it existed, otherwise you pick up the address assigned to the "accounts" table I used an inner for the second address join join because you said that the account always has an assigned address.

    Kind regards
    Randolf

    Oracle related blog stuff:
    http://Oracle-Randolf.blogspot.com/

    SQLTools ++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676 /.
    http://sourceforge.NET/projects/SQLT-pp/

Maybe you are looking for

  • Satellite L40: How can I recover the files from the hard drive

    Hello Can someone help me please. About a week ago I started to have a clicking sound coming from my laptop Satellite L40. My laptop froze and when I restarted, I was directed to the system configuration with a message at the bottom saying"Pri Master

  • I Phone 4, first time to the computer.

    bought Iphone 4, to replace my old IPhone3, and my computer is running to pick it up. I plug the USB and I hear the sound normal, but computer will not recognize. What should do?

  • ND_SCANCLK_LINE in DAQmx

    migrated DAQmx, unexpected behavior at the time of the acquisition and the value. use NI 6013 PCI Card. I have some doubts in the migrated source code. Please check if I'm wrong or not. Old code: Select_Signal (DevNo, ND_PFI_2, ND_IN_CONVERT, ND_HIGH

  • BlackBerry smartphones, that I need help pls

    My blackberry application blackberry Messenger and the world does not work and I deleted and downloaded, app world it dosent always impossible to download anything whatsoever, to make things worse, it dosent click on about and even less to highlight

  • Accidentally changed wifi band setting, the wireless doesn't work anymore

    Hello So, we just installed a new router and everything was fine.  I had the idea in my head to change the band from 2.4 to 5, then find that my wireless adapter does not support 5.  Thus, the wifi does not work (even if it recognizes the my network