with clause multicolumn UPDATE

is it possible to use an existing query written with the clause as the source for the multicolumn UPDATE statement? I have:
with x as ( rowid as rid, ... ), y as ( ... ), z as ( ... )
select x.rid, x.a ... z.a .. z.z
from x join y on x.a = y.a and .. x.z = y.z
     y left join z on y.a = z.a and .. y.z = z.z
I would like to have:
update BIG_X
set ( a, b, .... z ) =
select [ appropriate columns from above with ] from ( [ here comes above with statement ] ) small_x
where BIG_X.rowid = small_x.rid
but it does not work. I found a few examples of single column updated, but is it possible to make the multicolumn update without using the MERGE statement (which does not use WITH as subquery source)?

Thank you

Both Nik and kendenny gave you the basic framework, it is sufficient is a liitle play with the structure of base in their posts, but...

SQL> select * from t;

        ID DESCR1     DESCR2
---------- ---------- ----------
         1 Red        Blue
         2 Green      Yellow

SQL> select * from t1;

        ID DESCR1     DESCR2
---------- ---------- ----------
         1 Apple      Blueberry
         2 Grape      Banana

SQL> update t
  2  set (descr1, descr2) = (select descr1, descr2
  3                          from (with samp_dat as (
  4                                   select * from t1)
  5                                select id, descr1, descr2
  6                                from samp_dat) sd
  7                          where t.id = sd.id);

2 rows updated.

SQL> select * from t;

        ID DESCR1     DESCR2
---------- ---------- ----------
         1 Apple      Blueberry
         2 Grape      Banana

John

Tags: Database

Similar Questions

  • Can I use a reference WITH clause in a JOIN?

    Is the syntactically correct query?

    WITH abc AS

    (

    SELECT a.col1 d,

    e a.col2

    substr(a.Col1,2) f

    FROM table1 a JOIN

    Table 1 b ON a.col1 = b.col1

    WHERE a.col2! = b.col2

    )

    SELECT id, name, date of birth, ssn

    FROM table3 LEFT OUTER JOIN (SELECT DISTINCT abc.d of ABC WHERE abc.f = 'EF') / * Please note the addition of the WHERE clause in the veiw inline * /.

    ON table3.id = abc.d

    I try to use "abc" with a JOIN. Are there restrictions WITH clause?

    Thank you!

    Post edited by: user11951344

    Hello

    user11951344 wrote:

    I apologize I addded the WHERE clause too in mode inline "abcd" (in your query) to understand the purpose. The purpose of doing an OUTER JOIN of "abc" with table3 is to check the "EF" State = abc.f. Please note the Add where clause to update in my original question now.

    I see the changes, but everything in #5 response still applies.  There is no need to make a join in this case.  The output depends entirely on table3.  You will get the same results no matter what, if anything it either, is in table1, so any reference to table1 does that complicate the query and makes probably slower.

  • How to use WITH Clause of Apex classic report

    Hello.

    I use Apex 4.2.1 on mod_plsq and Oracle 11 g 3.

    I need to create a report classic usiing a WITH clause in the SQL report.  Apex keeps throwing the error 'CAN finf SELECT statement.

    I then wrapped my report query in an envelope, SELECT * clause.  Apex then raises an error you need to use a variable LONG.

    How is - a uses a WITH clause in the report query.

    Here is my report query:

    SELECT *.

    Of

    (

    WITH W

    AS

    (

    SELECT

    MIN (W1. URMT_BTRS_PK URMT_BTRS_PK),

    MIN (W1. EARLIER_NOTICE_ID URMT_NOTICES_ID),

    TO_CHAR (MAX (W1. EARLIER_NOTICE_TYPE NOTICE_TYPE)),

    TO_CHAR (MAX (W1. NOTICE_TYPE)) | '- Day' EARLIER_NOTICE_TYPE_DESC,.

    MAX (W1. LATER_NOTICE_ID URMT_NOTICES_ID),

    TO_CHAR (MIN (W1. LATER_NOTICE_TYPE NOTICE_TYPE)),

    TO_CHAR (MIN (W1. NOTICE_TYPE)) | '- Day' LATER_NOTICE_TYPE_DESC,.

    W1. NOCHG_STATUS_ORDER,

    W1. CHG_STATUS_ORDER,

    W1. ADD_STATUS_ORDER,

    W1. REM_STATUS_ORDER

    Of

    (

    SELECT

    URMT_BTRS_PK,

    URMT_NOTICES_ID,

    NOTICE_TYPE,

    : P202_NOCHG_STATUS_ORDER AS NOCHG_STATUS_ORDER,

    : P202_CHG_STATUS_ORDER AS CHG_STATUS_ORDER,

    : P202_ADD_STATUS_ORDER AS ADD_STATUS_ORDER,

    : P202_REM_STATUS_ORDER AS REM_STATUS_ORDER

    Of

    V_URMT_COMPARE_NUCLIDE_DATA

    WHERE

    URMT_NOTICES_ID IN (TO_NUMBER(:P202_COMPARE_EARLER_NOTICE_ID), TO_NUMBER (:P202_COMPARE_LATER_NOTICE_ID))

    ) W1

    )

    ------------------

    SELECT

    CASE WHEN (X.STATUS IS NULL) THEN

    CASE WHEN (INSTR(X.MASS ||)

    X.NUCLIDE_FRACTION

    ((' *', 1, 1) > 0) THEN '< div class = "chg_highlight" >' | HTF. ESCAPE_SC (' changed (' |)) (SELECT EARLIER_NOTICE_TYPE |) ' => ' || LATER_NOTICE_TYPE | ((' W)) | "< / div >"

    Else 'no change '.

    END

    WHERE (X.STATUS = 'Added') THEN ' < div class = "add_highlight" > ' | HTF. ESCAPE_SC(X.STATUS ||) "To" | (BY SELECTING LATER_NOTICE_TYPE_DESC IN W)) || "< / div >"

    WHERE (X.STATUS = 'Deleted') THEN "< div class ="rem_highlight"> ' |" HTF. ESCAPE_SC(X.STATUS ||) 'From ' | (BY SELECTING EARLIER_NOTICE_TYPE_DESC IN W)) || "< / div >"

    OF OTHER X.STATUS

    END AS STATUS

    ----

    CASE WHEN (X.STATUS_ORDER IS NULL) THEN

    CASE WHEN (INSTR(X.MASS ||)

    X.NUCLIDE_FRACTION

    ((' *', 1, 1) > 0) THEN (SELECT CHG_STATUS_ORDER FROM W)

    OTHER (SELECT NOCHG_STATUS_ORDER FROM W)

    END

    OF OTHER X.STATUS_ORDER

    END AS STATUS_ORDER,

    ----

    X.NUCLIDE,

    ----

    CASE WHEN (X.STATUS IS NULL) THEN

    BOX WHEN (SUBSTR (X.MASS, 1, 1) = ' *') THEN SUBSTR (X.MASS, 2).

    OF OTHER X.MASS

    END

    OF OTHER X.MASS

    MASS OF THE END AS,

    ----

    CASE WHEN (X.STATUS IS NULL) THEN

    BOX WHEN (SUBSTR (X.NUCLIDE_FRACTION, 1, 1) = ' *') THEN SUBSTR (X.NUCLIDE_FRACTION, 2).

    OF OTHER X.NUCLIDE_FRACTION

    END

    OF OTHER X.NUCLIDE_FRACTION

    END AS NUCLIDE_FRACTION

    Of

    (

    -THE NUCLIDES EXIST IN * TWO * BEFORE AND AFTER VIEW.  SOME OF THEIR ATTRIBUTES (MASS, NUCLIDE_FRACTION, ETC.)  MAY HAVE CHANGED.

    SELECT

    STATUS AS NULL,

    VALUE NULL AS STATUS_ORDER,

    C.NUCLIDE,

    BOX WHEN (NVL (C.A_MASS, 'Null')! = NVL (C.B_MASS, 'Null')) THEN ' *' | '< div class = "chg_highlight" >' | HTF. ESCAPE_SC (NVL (C.A_MASS, 'Null') |) ' => ' || NVL (C.B_MASS, 'Null')) | "< / div >"

    Of ANOTHER NVL (C.B_MASS, 'Null')

    MASS OF THE END AS,

    ----

    BOX WHEN (NVL (C.A_NUCLIDE_FRACTION, 'Null')! = NVL (C.B_NUCLIDE_FRACTION, 'Null')) THEN ' *' | '< div class = "chg_highlight" >' | HTF. ESCAPE_SC (NVL (C.A_NUCLIDE_FRACTION, 'Null') |) ' => ' || NVL (C.B_NUCLIDE_FRACTION, 'Null')) | "< / div >"

    Of ANOTHER NVL (C.B_NUCLIDE_FRACTION, 'Null')

    END AS NUCLIDE_FRACTION

    Of

    (

    SELECT

    A.NUCLIDE,

    TO_CHAR(A.MASS, '999.99EEEE') AS A_MASS,

    TO_CHAR(A.NUCLIDE_FRACTION, '99999.999EEEE') AS A_NUCLIDE_FRACTION,

    ----

    TO_CHAR(B.MASS, '999.99EEEE') AS B_MASS,

    TO_CHAR(B.NUCLIDE_FRACTION, '99999.999EEEE') AS B_NUCLIDE_FRACTION

    Of

    V_URMT_COMPARE_NUCLIDE_DATA, A.

    V_URMT_COMPARE_NUCLIDE_DATA B

    WHERE

    1 = 1

    AND A.URMT_BTRS_PK = B.URMT_BTRS_PK

    AND A.NUCLIDE = B.NUCLIDE

    AND A.URMT_BTRS_PK = (SELECT URMT_BTRS_PK FROM W)-TO_NUMBER(:P202_URMT_BTRS_PK)

    AND A.URMT_NOTICES_ID = (SELECT EARLIER_NOTICE_ID FROM W) - TO_NUMBER(:P202_COMPARE_EARLER_NOTICE_ID) - PRIOR NOTICE (EXAMPLE: 30 DAYS)

    AND B.URMT_NOTICES_ID = (SELECT LATER_NOTICE_ID FROM W) - TO_NUMBER(:P202_COMPARE_LATER_NOTICE_ID) - FURTHER VIEWS (EXAMPLE: 7 DAYS.)  NOTE: PRIOR NOTICE IS COMPARED WITH OPINIONS LATER, FOR EXAMPLE, 30 DAYS IS COMPARED TO 7 DAYS)

    ) C

    UNION

    -ADDED NOTICE LATER NUCLIDES.  THEY DO NOT APPEAR IN THE EARLIER OPINION.

    SELECT

    "Added" AS the STATUS,

    (BY SELECTING ADD_STATUS_ORDER IN W) AS STATUS_ORDER,

    A.NUCLIDE,

    TO_CHAR(A.MASS, '999.99EEEE') AS A_MASS,

    TO_CHAR(A.NUCLIDE_FRACTION, '99999.999EEEE') AS A_NUCLIDE_FRACTION

    Of

    V_URMT_COMPARE_NUCLIDE_DATA HAS

    WHERE

    1 = 1

    AND A.URMT_BTRS_PK = (SELECT URMT_BTRS_PK FROM W)-TO_NUMBER(:P202_URMT_BTRS_PK)

    AND A.URMT_NOTICES_ID = (SELECT LATER_NOTICE_ID FROM W)-TO_NUMBER(:P202_COMPARE_LATER_NOTICE_ID)

    AND NOT EXISTS

    (SELECT NULL

    OF V_URMT_COMPARE_NUCLIDE_DATA B

    WHERE B.URMT_BTRS_PK = A.URMT_BTRS_PK

    AND B.NUCLIDE = A.NUCLIDE

    AND B.URMT_NOTICES_ID = (SELECT EARLIER_NOTICE_ID FROM W)-TO_NUMBER(:P202_COMPARE_EARLIER_NOTICE_ID)

    )

    UNION

    -DELETED THE PREVIOUS NOTICE NUCLIDES.  THEY DO NOT APPEAR IN THE NOTICE LATER.

    SELECT

    'Removed' AS the STATUS,

    (BY SELECTING REM_STATUS_ORDER IN W) AS STATUS_ORDER,

    A.NUCLIDE,

    TO_CHAR(A.MASS, '999.99EEEE') AS A_MASS,

    TO_CHAR(A.NUCLIDE_FRACTION, '99999.999EEEE') AS A_NUCLIDE_FRACTION

    Of

    V_URMT_COMPARE_NUCLIDE_DATA HAS

    WHERE

    1 = 1

    AND A.URMT_BTRS_PK = (SELECT URMT_BTRS_PK FROM W)-TO_NUMBER(:P202_URMT_BTRS_PK)

    AND A.URMT_NOTICES_ID = (SELECT EARLIER_NOTICE_ID FROM W)-TO_NUMBER(:P202_COMPARE_EARLER_NOTICE_ID)

    AND NOT EXISTS

    (SELECT NULL

    OF V_URMT_COMPARE_NUCLIDE_DATA B

    WHERE B.URMT_BTRS_PK = A.URMT_BTRS_PK

    AND B.NUCLIDE = A.NUCLIDE

    AND B.URMT_NOTICES_ID = (SELECT LATER_NOTICE_ID FROM W)-TO_NUMBER(:P202_COMPARE_LATER_NOTICE_ID)

    )

    ) X

    )

    I have searched this forum for clues but found nothing.

    Any help would be appreciated.

    Thank you.

    Elijah

    EEG wrote:

    I'll now try to place my report within a packaged procedure, and then run it from there.  You don't love doing cela, but seem to don't have is not a choice.

    Elijah

    Huh?  How can you put a SELECT statement in a procedure?  you return a cursor reference?

    You create VIEWS.  You have three sections.  Give an opinion on each of them.  Test them with SQL Developer (or SQL * more)

    Build from there.

    In fact, it looks like you are trying to compare two tables"and return a DIFF

    THINKING IN SETS

    Use the WITH clause to build a 'virtual' table for EARLIER_NOTICE and a 'virtual' table for LATER_NOTICE.

    Use FULL OUTER JOIN to compare the two.

    THE FORMAT OF THE EXAMPLE:

    select * from (
    with w as ( .... )
    ,table_A as ( -- build the Virtual Table for EARLIER_NOTICE
    SELECT *
     FROM
     V_URMT_COMPARE_NUCLIDE_DATA A1
       join W on (A1.urmt_btrs_pk, W.urmt_btrs_pk  and A1.earlier_notcie_id=W.earlier_notice_id)
    
    --  old code
    -- WHERE
    -- 1 = 1-- why???
    -- AND A.URMT_BTRS_PK     = (SELECT URMT_BTRS_PK FROM W)    --TO_NUMBER(:P202_URMT_BTRS_PK)
    -- AND A.URMT_NOTICES_ID = (SELECT EARLIER_NOTICE_ID FROM W)   --TO_NUMBER(:P202_COMPARE_EARLER_NOTICE_ID)
    ,table_b as ( -- build the Virtual Table for the LATER_NOTICE
    
     select *
     from
    
     V_URMT_COMPARE_NUCLIDE_DATA B1
       join W on (b1.urmt_btrs_pk = W.urmt_btrs_pk  and b1.urmt_notice_id=W.later_notice_id)
    )
    
    --/*** NOW - WE COMPARE THE TWO ***/
    select CASE
        when A.urmt_btrs_pk is null then 'ADDED'
        when B.urmt_btrs_pk is null then 'DELETED'
        else 'possibily updated'
    end CHANGES_MADE
      , A.*
      , B.*
    
    FROM TABLE_A A FULL OUTER JOIN B
    ON (
     A.URMT_BTRS_PK = B.URMT_BTRS_PK
    AND A.NUCLIDE = B.NUCLIDE )
    




  • What happened to all my music purchased with the recent update?

    What happened to all my music bought with the last update?

    You should be able to find one of your purchases and restoration if you connect your device to itunez on a pc if this does not help you can try looking in your email through your iphone at the top of the screen try typing a bill or itunes, it will search that then the emails from purchases to itunes which must have an order number on your music purchases and then contact customer support for itunes If you can not restore your music hope it helps to have a good day

  • Problem with the new update

    Any browser looks graphically unstable and content is empty with the new update, is it just me or is just the update which is unstable?

    Hello

    Try disabling graphics hardware acceleration. You will have to perhaps restart Firefox for it to take effect, so save any work first (e.g. you compose mail, documents online that you are editing, etc.).

    Then perform the following steps:

    1. Click the menu button

      then select Options Preferences on Mac or Linux, or Windows.

    2. In the window of Firefox Options (or preferences), click on the Advanced tab, and then select general.
    3. You will find in the list of parameters, the checkbox use hardware acceleration when available . Clear this check box.
    4. Now restart Firefox and see if the problems persist.

    In addition, please check the updates for your graphics driver by following the steps in the following knowledge base articles:

    This solve your problems? Please report to us!

    Thank you.

  • Lost all my tabs open with the last update

    I've updated Firefox with your last update of security and since then Firefox would freeze with a script error when I tried to go to one of my tabs. I followed the troubleshooting instructions and he created a "Old Data" folder in my office, but the new page of Firefox did not my tabs. How can I get back them? Can I cancel the update and return to the previous state of Firefox before the update?

    (edited to replace labels with tabs - c)

    Thank you all for trying to help. Here's what needs to be done to solve the problem when Firefox is installed on a mac. When you tried to reset your profile, note that there is a folder created in your desktop called 'Old Foxfire Data' or similar to this one. It contains all the data that has been cleaned up in the new profile. Delete the Firefox application and download a new application of Foxfire. Then launch Firefox. When open go in the tab 'Help', above. It's the last of them. Once you click on help, then click on "troubleshooting information. The first section is called "Basic application". In this section, click on the tab "show in Finder". It will display your profile folder. It starts with a letter and then a bunch of numbers and letters. But it will contain '.default' and some other figures. Now go to the first folder in your office called old data Foxfire and open it. Note that it will also have a similar profile folder. Open it and go to this folder copy all 80 more files. Now go to the new profile folder, open it and paste all files in this folder from backup profile to the profile folder. Click Yes to replace all the files that you paste into the new profile folder. That's all. Close, close and restart Firefox. You will have all your history, bookmarks and any label that you had open before the crash. Also, I say stop mac and restarted the computer, so that all possible conflicts would be eliminated. PS: The deletion of your profile folder and paste the old folder in its place it will not work! You need to replace all of the files in the new folder with the files from your profile in the old data folder.

  • iPhone 5 volume cannot be reduced with (-) button after update to 9.3.2

    Volume cannot be reduced with button after update to 9.3.2

    Can increase the volume with button until the max volume.

    Cannot lower volume in any application that has sound.

    This on the iPhone 5 with iOS 9.3.2

    Try a Reset: press and hold the sleep/wake button and the Home button at the same time for at least 10 seconds, until the Apple logo appears. -Note: no data will be lost

  • How to set the location of the function "reload the page" with the new update?

    Since the new update, my previous settings have been changed and I can't get back them.
    I could already right-click and customize what I wanted to see, now, I have a "menu open from the things I've decided I don't want to see" option stuck right without an option to not see. Okay so.

    My main problem is that all of my computers I always 'Reload the page' and "Stop reload the page" options to the left of the URL bar. With the new update, ironically designed to make easier user interface customization, they are stuck in a slot inside the URL bar.

    I wonder if anyone knows a way to customize it? Please and thank you.

    Sorry, in Firefox 29 the reload / Stop button drop-down list is not movable. But there are extensions available to restore this preference.

    This extension is popular, for example.

    https://addons.Mozilla.org/en-us/Firefox/addon/classicthemerestorer/

  • Print problems with the recent update to Version 10.11.5

    Print problems with the recent update to the Version of El Capitan 10.11.5.  Cannot print to my Epson and Samsung printers after update to new IOS.  Print jobs get hooked on my Mac Pro.

    Roger 510 wrote:

    Print problems with the recent update to the Version of El Capitan 10.11.5.  Cannot print to my Epson and Samsung printers after update to new IOS.  Print jobs get hooked on my Mac Pro.

    Have you checked with Epson for an updated printer driver?

  • The Roboform plugin still fails to work with the new update?

    RoboForm has disappeared with the new update. I went back to the old version. WORKS very well...

    The latest version of RoboForm (7.6.7) is perfectly compatible with Firefox 8. Siber Systems generally offer an update within 24 hours otherwise before compatibility when an up-to-date browser. They also have live telephone support large if you have any questions.

  • seems I'm not the only one having problems with safari after update 9.3 cannot follow the links. Safari blocks. hope it gets fixed quickly. jaa shooting allows to follow the link, but the Web page is not out of good old days. any oher ideas?

    seems I'm not the only one having problems with safari after update 9.3 cannot follow the links. Safari blocks. hope it gets fixed quickly. jaa shooting allows to follow the link, but the Web page is not out of good old days. any oher ideas?

    The 'list' of relevant articles that I know, they are now

    -You can read about the problems in the present statutes and possibly find workaround solutions, particularly in the last

    If you are unable to activate your iPhone, iPad or iPod touch after installing an update - Apple Support

    Apple iOS suspension 9.3 updates for older devices, work on activation fix | IVous

    Apple launches new version of iOS for iPad users 9.3 2 affected by bricking bug | 9to5Mac

    GSM of unfixed addresses Apple iPad 2 Bug with revised Activation iOS 9.3, but the larger question remains - Mac rumors

    If you are unable to activate your iPad 2 (GSM model) update to iOS 9.3 - Apple Support

    9.3 iOS update issues

    Leave a post by: ChitlinsCC

  • Hard reset does not not with 9.3 update

    With the new update, I can't hard reset my iPhone. Siri does not work all the time. Sometimes when I reset hard my phone unlocks even if I'm not using my footprint.

    You could try these:


    1. Restart: press start/stop button until the Slide to Power Off slider appears, select Slide to Power Off and after it stops, press on On / Off button until the Apple logo appears.
    2. Reset: press the home and On / Off buttons at the same time and hold them until the Apple logo appears (about 10-15 seconds).
    3. Restoration: connect your iPhone to iTunes on your computer, backup, and then select factory restore
  • Apple not recognized with the new update ID

    What now, after the update

    Apple not recognized with the new update ID!

    I have the same question. The user and the password are ok because I can log in here: https://appleid.apple.com

    But after the last update my iPad say that "the apple ID or the password is incorrect."

  • My iPhone with iOS 9.2.1 5s is deleting random contacts.  This happened for several months is not just with the last update of iOS.  Any suggestions?

    My iPhone with iOS 9.2.1 5s is deleting random contacts.  This happened for several months is not just with the last update of iOS.  It deletes recently used contacts and removes also from my iPad.  Any suggestions?

    That you synchronize your contacts with? A decision-making application supported on the computer, a Cloud Computing service?

  • I used numbers for a long time, but only make spreadsheets base.  With the latest updates, I couldn't change my information.  What Miss me?

    I used numbers for a long time, but only make spreadsheets base.  For about a year and with the latest updates, I couldn't change my information.  What Miss me?

    Hi Deb,

    There not really enough information in your message to help you. How things don't work, exactly? Is there any alerts or messages?

    Quinn

Maybe you are looking for

  • Please explain the connection points

    I am new to FCPX and I spent a lot of time searching for the answer to the following without success. What exactly are the "connection points"? I thought that if I moved to the location of a point of connection a video clip would begin at this new, b

  • See questions based on SQL.

    Hi once again, everythingI use Jdev 12.1.3. I have a SQL view opposed based on a rather complex SQL query in my ADF application.This query has 5 parameters for which I created 5 bind variables.(A) Comment can I fill these variables programmatically?

  • I have a new laptop and try to download a cloud that Photoshop crashes to the screen how can I go back to photoshop cc2014

    I have a new laptop and try to download a cloud Fotoshop blocks on the screen how can I go back to photoshop cc2014 @.

  • Problem publishing Flash Movie

    I have an assignment for my college web design class in the flash section. We had to create these flash animations to teach basic skills. I finished the project very well, and it plays when I test in flash professional, and when I test the publicatio

  • Tumblr Blog causing Crash

    I have an existing site created by Muse.At the opening of the site in Muse cc 2014 two thing happening on the blog embedded tumblr.1. it does not display correctly it must be centered where as seems to be left aligned? See photos attached2. when I tr