Several passes update query

I tried to update several columns using the query below and the error message received
ORA-01427: einreihig subquery returns multiple rows

Also, perhaps because I could not get this work was the reason for which the original did not work in which I tried to recover the data from a With statement and otherwise, did a create table. Would be a statement work in writing a query update?
update
      transf_cohort1
      set (primary_ethnicity, citizenship_type, residency, cwid, cohort_pidm,bansid) = 
          (select plus.primary_ethnicity,
                  plus.citizenship_type,
                  plus.residency,
                  plus.cwid,
                  plus.cohort_pidm,
                  plus.bansid
            from plus_coh plus
            inner join transf_cohort1
            on transf_cohort1.sid = plus.sid
            where transf_cohort1.cohort_pidm is null
                                  
          )
    ; 

Thank you, never liked type ;-)

Concerning

Etbin

for the OP

update
      transf_cohort1 t_c
      set (primary_ethnicity, citizenship_type, residency, cwid, cohort_pidm, bansid) =
          (select primary_ethnicity, citizenship_type, residency, cwid, cohort_pidm, bansid
             from (select plus.primary_ethnicity,
                          plus.citizenship_type,
                          plus.residency,
                          plus.cwid,
                          plus.cohort_pidm,
                          plus.bansid,
                          transf_cohort1.unique_column  /* @ */
                     from plus_coh plus inner join transf_cohort1
                                        on transf_cohort1.sid = plus.sid
                    where transf_cohort1.cohort_pidm is null
                  )
            where unique_column  /* @ */ = t_c.unique_column  /* @ */
          )
      where t_c.unique_column /* @ */ in (select transf_cohort1.unique_column  /* @ */
                                    from plus_coh plus inner join transf_cohort1
                                                       on transf_cohort1.sid = plus.sid
                                   where transf_cohort1.cohort_pidm is null
                                 )

Edited by: Etbin on 10.6.2010 23:14
added comment / * @ * / do more easily locate

so be sid (according to the post, below)

update
      transf_cohort1 t_c
      set (primary_ethnicity, citizenship_type, residency, cwid, cohort_pidm, bansid) =
          (select primary_ethnicity, citizenship_type, residency, cwid, cohort_pidm, bansid
             from (select plus.primary_ethnicity,
                          plus.citizenship_type,
                          plus.residency,
                          plus.cwid,
                          plus.cohort_pidm,
                          plus.bansid,
                          transf_cohort1.sid
                     from plus_coh plus inner join transf_cohort1
                                        on transf_cohort1.sid = plus.sid
                    where transf_cohort1.cohort_pidm is null
                  )
            where sid = t_c.sid
          )
      where t_c.sid in (select transf_cohort1.sid
                          from plus_coh plus inner join transf_cohort1
                                             on transf_cohort1.sid = plus.sid
                         where transf_cohort1.cohort_pidm is null
                       )

Edited by: Etbin on 10.6.2010 23:23

Tags: Database

Similar Questions

  • Windows has repeatedly several times updated

    Windows has repeatedly several times updated KB2310138, KB2686827, KB2656405, KB265368, KB2604121, KB2656351 and still wants to update, use the hotfix from microsoft and he always does. Windows Vista.

    Hi Libby,

    I see that you are offered to install updates KB2310138, KB2686827, KB2656405, KB265368, KB2604121 and KB2656351 several times.

    You can follow all the methods listed in the article mentioned below to solve the problem:

    Troubleshooting Windows Update or Microsoft Update when you are repeatedly offered an update

    http://support.Microsoft.com/kb/910339

    Note: The article applies both to Windows Update in Windows Vista.

    It will be useful. For any other corresponding Windows help, do not hesitate to contact us and we will be happy to help you.

  • Several windows updates are not installed and the error code given is 66A

    Original title: updates

    Several windows updates are not installed and the error code given is 66. However the error is considered to be unknown and the code is not useful to find a solution. Anyone know what the code means, or we mean?

    Hello

    1 did you change on your computer before this problem?

    Follow the suggestions and check if it works.

    Method 1

    You can reset Windows Update components and see if it works fine.

    How to reset the Windows Update components?
    http://support.Microsoft.com/kb/971058
    Method 2

    You can download and run the system update readiness tool.

    Description of the update tool of the system to Windows Vista, Windows Server 2008, Windows Server 2008 R2
    http://support.Microsoft.com/kb/947821

    See also:

    Error code '0x8007066A' or "66" when you use the Windows Update Web site or Microsoft Update to install the .net Framework update

    http://support.Microsoft.com/kb/2507641/en-us

  • Why Disk Defragmenter made several passes?

    original title: Disk Defragmenter

    Why Disk Defragmenter made several passes?

    7 days since the beginning and now the third pass and consolidation.

    John

    This topic deals with your original question.

    http://hardforum.com/showthread.php?t=1567990

    It is not definitive, but the debate has highlighted a number of points.

    Personally, I use Defraggler because it has a better user interface and allows me to better control the defragmentation process.

    http://www.Piriform.com/Defraggler

    E partition unless you free disk space by 15% while the system will struggle to, if not fail to, defragment the partition. Before Defragmenting, it would be better to increase the available disk space on the partition to about 25%.

    Which files contains the partition? The computer is a desktop or laptop computer? What is the hard drive?

  • Update query not in AND not exists

    The following update query hangs

    {code}

    Update EMP

    define the EMP. SAL_FLAG = 1

    EMP. SAL_EFFECTIVE_DATE = to_date ('20140101', 'YYYYMMDD')

    If EMP.ID not in (SELECT ID

    of the Department

    When TREATED = 'Y '.

    )

    AND EMP. SAL_FLAG = 0

    AND EMP. SAL_EFFECTIVE_DATE < = to_date ('20140101', 'YYYYMMDD')

    {code:}

    Out of the PLAN is

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

    | ID | Operation | Name                     | Lines | Bytes | Cost |    TQ | IN-OUT | PQ Distrib.

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

    |   0 | SELECT STATEMENT |                          | 13700 |   254K |    22 M |        |      |            |

    |*  1 |  FILTER |                          |       |       |       |        |      |            |

    |   2.   COORDINATOR OF PX |                          |       |       |       |        |      |            |

    |   3.    PX SEND QC (RANDOM). : TQ20000 | 13700 |   254K |  1995 |  Q2, 00 | P > S | QC (RAND) |

    |   4.     ITERATOR BLOCK PX |                          | 13700 |   254K |  1995 |  Q2, 00 | ISSUE |            |

    |*  5 |      TABLE ACCESS FULL | EMP                      | 13700 |   254K |  1995 |  Q2, 00 | SVCP |            |

    |   6.   COORDINATOR OF PX |                          |       |       |       |        |      |            |

    |   8 S    PX SEND QC (RANDOM). : TQ10000 |     2.    20.  3334.  Q1 00 | P > S | QC (RAND) |

    |   8.     ITERATOR BLOCK PX |                          |     2.    20.  3334.  Q1 00 | ISSUE |            |

    |*  9 |      TABLE ACCESS FULL | DEPT                     |     2.    20.  3334.  Q1 00 | SVCP |            |

    Can someone help me solve this problem? The TWO ID of 2 tables have an index

    Waiting for your spare update queries

    Thank you

    S

    Maybe

    merge into e emp

    using (select id

    of the Department

    when transformed! = « Y »

    ) d

    on (e.id = d.id)

    when matched

    then update

    Set e.sal_flag = 1,

    e.effective_date = date ' 2014-01-01'

    Concerning

    Etbin

  • Update query with join statement

    Hi guys, would check how to write a query to update with the inner join statement? The case is like this, I need to update PRD_ID on TBL A as below, based on the information of lookup table. The keys are based on the A03 column to the table time to condition only select records in LOOKUP_TBL where PRD_ID = 110001 then update to TBL_A for those who match the data and FIX_FLT = 1

    I have an update query and it works in SQL SERVER but not in ORACLE

    Update a PRD_ID = B.PRD_ID set

    Inner TBL_A A join B LOOKUP_TBL

    On A.A03 = B.A03

    AND A.FIX_FLT = 1 AND B.PRD_ID = '110001';

    TBL_A

    PRD_IDA03FIX_FLTTXNDATE
    1A11123/10/2010
    1A21110/24/2010
    1A33210/25/2010
    1A43210/26/2010
    1A53127/10/2010

    LOOKUP_TBL

    PRD_IDA03NOTE
    110001A1NULL VALUE
    110001A2NULL VALUE
    110005A3NULL VALUE
    110005A4NULL VALUE
    110001A5NULL VALUE

    You can write updates like this in Oracle.  It's called updatable join views.  Something like this:

    Update
    (select a.prd_id a_prd_id
    b.prd_id b_prd_id
    Inner TBL_A A join B LOOKUP_TBL
    On A.A03 = B.A03
    AND A.FIX_FLT = 1 AND B.PRD_ID = '110001'
    )
    Set a_prd_id = b_prd_id;

    But you must have the constraints appropriate in place, otherwise you will get the error "key preserved table.

  • Error in database engine Microsoft JET '80004005' operation must use an update query.  / fax_remove/index.asp, line 115

    everything began to receive the following error message

    Microsoft JET Database Engine error '80004005'

    Operation must use an update query.

    /fax_remove/index.asp line 115


    for the following Web page

    Remove.canchair.com


    no coding changes have been achieved

    Use your host control panel to check the permissions of the remote folder that contains the mdb and the mdb itself. Contact your host if you are unsure how to proceed.

  • pass the query id in the pop up window

    Hello

    I want to be able to pass the query id in the pop up window but do not know how to do it, would you please help me with this? -Thank you

    the code below (A) works very well with open the pop-up page detail but din't know how there an id in the details of the page.

    <!--A-->

    < script >

    function openWin()

    {

    Window.Open ("detail.cfm,", "_blank", "toolbar = yes, scrollbars = yes, resizable = yes, high = 500, left = 500, width = 400, height = 400");

    }

    < /script >

    < cfset foo = querynew ("id_int, aNo_var, Renew, Cancel') >

    < cfloop query = "getOrderHist" >

    < cfset queryaddrow (foo) >

    < cfset querysetcell (foo, 'id_int', getOrderHist.id_int) >

    < cfset querysetcell (foo, 'aNo_var', getOrderHist.aNo_var) >

    < cfset querysetcell (foo, 'Renew',' < a href = "javascript: void (0);" onclick = "openWin ()" > view < /a > ') >

    < / cfloop >

    <! - B - >

    I try to call the page directly such as below but got an error of "invalid character".

    < cfset foo = querynew ("id_int, aNo_var, Renew, Cancel') >

    < cfloop query = "getOrderHist" >

    < cfset queryaddrow (foo) >

    < cfset querysetcell (foo, 'id_int', getOrderHist.id_int) >

    < cfset querysetcell (foo, 'aNo_var', getOrderHist.aNo_var) >

    < cfset querysetcell (foo, 'Renew',' < a href = "javascript: void (0);" onclick = "window.open("detail.cfm?id=#id#","_blank"); > < /a > to renew '") >

    < / cfloop >

    you have a 'openWin' function, but then you try to add inline JS to do the same thing.  I suppose you're eventually loop over your query "foo" output these links to renew.  In this case, I just want to pass a URL or just the ID into the openWin function.  Much simpler than to try to add dynamic JS in a cell of the query.

    I am a bit confused why you are creating a new query, foo, if you already have the query getOrderHist that seems to have everything you need.

    function openWin (id) {}

    Window.Open ("detail.cfm? id =" + id, "_blank", "toolbar = yes, scrollbars = yes, resizable = yes, high = 500, left = 500, width = 400, height = 400");

    }

    ID: #getOrderHist.id_int #.

    aNo: #getOrderHist.aNo_var #.

    Renew

  • I must be the most simple update query!

    Hi all

    I'm trying to run an update query that should be simple, that he gets, an inner join between two tables setting the value of a column non-joining tables to the value of the other tables non-joining column:

    SQL > update compound c
    2 set cmpname =)
    3. Select xname
    temp_foo 4 f
    5 where c.cmpcorporateid = f.xcorpid);

    146917 lines to date.

    Problem is that temp_foo has only one record and that only one record is a record in the compounds. How to limit the search to this record?

    Thanks for any help!

    Hello

    Since you do not have a WHERE clause in the UPDATE statement itself, all rows will be modified.
    Try this:

    update  compounds      c
    set      cmpname = (
                select  xname
                from        temp_foo     f
                where   c.cmpcorporateid = f.xcorpid
                )
    -- From here down is all new
    WHERE   xcorpid IN (
                 SELECT  cmpcorporateid
                 FROM        temp_foo
                 );
    

    If you think that's duplicate most of the work of the subquery, you are absolutely right!
    You can use the MERGE command to avoid this kind of duplication.

  • Update query does not work (ora-01427)

    RDBMS 10 g 2

    Long story short, I created a column in a table in another table, that it has been moved is not really necessary that all other information is stored in other tables. With the original column has values that need to be copied to the new column before the old table is deleted.

    I use this update query:
    update bi_req bir
       set bir.job_name =
            (select distinct bij.job_name
               from bi_jobs bij,
                    bi_freq bif,
                    bi_apps bia,
                    bi_req  bir
              where bij.fk_bi_req_id = bir.pk_bi_req_id
                and bia.pk_bi_apps_id = bij.fk_bi_apps_id
                and bif.pk_bi_freq_id = bij.fk_bi_freq_id)
     where bir.job_name is null;
    If I run the select statement separately, I get the exact results that I need however, every time I run the whole statement, I get:
    Error: ORA-01427: single-row subquery returns more than one row

    The problem is that your subquery returns two or more names different jobs for a line of update.

    Which of these task names are you using? If it is not serious, then you can go with a like this aggregate query

    update bi_req bir
       set bir.job_name =
            (select max(bij.job_name) /* use just one job name */
               from bi_jobs bij,
                    bi_freq bif,
                    bi_apps bia
            where bij.fk_bi_req_id = bir.pk_bi_req_id
                and bia.pk_bi_apps_id = bij.fk_bi_apps_id
                and bif.pk_bi_freq_id = bij.fk_bi_freq_id)
     where bir.job_name is null;
    

    What I don't understand is why you need the bi_freq and bi_apps in the subquery. A simple query as follows: should not be enough?

    update bi_req bir
       set bir.job_name =
            (select max(bij.job_name) /* use just one job name */
               from bi_jobs bij
            where bij.fk_bi_req_id = bir.pk_bi_req_id)
     where bir.job_name is null;
    

    Published by: W. Sven on September 4, 2009 14:06

  • [Microsoft] [ODBC Microsoft Access driver] Operation must use an update query.

    Trying to insertion or put to update an access database I get on the error message:

    [Microsoft] [ODBC Microsoft Access driver] Operation must use an update query.

    What is the cause of this, and what could be the solution?

    Thank you.

    Ross

    I discovered after testing that the directory where the database file resides must be barking like rwx as well - not intuitively obvious, certainly!

    I ended up creating a new directory with the file of database inside also well marked for write access in the world and relying on my permissions of normal file off root on the server to protect the directory and file.

    Thank you!

    Ross

  • Update query help

    Hello


    Hello
    Can be simple, but I'm still learning...
    I want to update the value column for table1 based on the table2 by using the SQL query.
    TABLE1               TABLE2     
    Name        Value     Name       Value
    A                 A       10
    B                 B       20
    C                 C       30
    B                        
    B                        
    C                             
    A                             
    B     
    Thank you
    Killian

    Hey Killian,

    You can use the joint related query to update the value of table1 based on the table2

    # If several passenger/PNR are in table2 then update table1 will fail because of multiple returned records
    # When no record is found in table2, then will have the value NULL

    UPDATE TABLE1 t1
    SET t1.value = ( SELECT t2.value
                     FROM TABLE2 t2
                     WHERE t1.name = t2.name
                     ) 
    
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
    
  • Update query with case

    my table: workingdate

    SNO name startdate
    1 ss 12/01/2011
    2 bb 11/01/2011


    I can update name or date start or two .i will pass a new date, name of update through front end.

    I need to validate the condition in the event, that is when the new date after check if it is higher, then start date. If it is higher, then it should be updated with the new start date.
    If not, it must be updated, it will be the old value.

    I use it under request

    Update workingdate set name = 'sss', startdate =)
    case
    When
    (TO_DATE('2011-12-10','yyyy-MM-dd') > (select TO_DATE(startdate,'yyyy-MM-dd') from the workingdate, when sno = 1))
    then TO_DATE('2011-12-10','yyyy-MM-dd')
    on the other
    Select TO_DATE(start_date,'yyyy-MM-dd') in the workingdate, when sno = 1
    end
    )
    where sno = 1;


    but when I run the above query, it shows me


    Error report:
    SQL error: ORA-00936: lack of expression
    00936 00000 - "missing expression.
    * Cause:
    * Action:

    How could I solve this problem...

    Check this

    UPDATE workingdate
    SET NAME='sss',
         startdate=(CASE WHEN (TO_DATE('2011-12-10','yyyy-MM-dd') > startdate THEN TO_DATE('2011-12-10','yyyy-MM-dd') ELSE start_date END)
    WHERE sno=1;
    

    See you soon
    Kanchana

  • I want the single update query without using the function.

    I want to update sells_table selling_code field with product_code date product table max.
    In the product table, there are several product_code date wise.

    I did with below charly with the use of the service, but we can do in the query what a single update
    without using the function.

    UPDATE sells_table
    SET selling_code = MAXDATEPRODUCT (ctd_vpk_product_code)
    WHERE NVL(update_product_flag,0) = 0;

    (P_product IN VARCHAR2) RETURN of HVL.maxdateproduct NUMBER FUNCTION to CREATE or REPLACE
    IS
    max_date_product VARCHAR2 (100);
    BEGIN
    BEGIN
    SELECT NVL (TRIM (product_code), 0)
    IN max_date_product
    FROM (SELECT product_code, xref_end_dt)
    PRODUCT
    WHERE TO_NUMBER (p_product) = pr.item_id
    ORDER BY xref_end_dt DESC)
    WHERE ROWNUM = 1; -He'll be back a single line - max date product code
    EXCEPTION
    WHILE OTHERS
    THEN
    RETURN 0;
    END;

    RETURN max_date_product;

    END maxdateproduct;

    Thanks in advance.

    Hello

    Something like that.

    update setlls_table st
            set selling_code =(select nvl(trim(product_code)) from
                                  (select product_code
                                          , rank() over (partition by item_id order by xref_end_dt DESC) rn
                                       from product
                                   ) pr
                                   where rn =1
                                         and pr.item_id = st.ctd_vpk_product_code
                               ) where NVL(update_product_flag,0) = 0 ;
    

    That such is not tested due to lack of sampling input.

    Concerning
    Anurag Tibrewal.

  • Error code: 646 (impossible to install several Office updates)

    Updates: KB982312 KB982308 KB979441 KB982158, KB979440, KB982124, KB982135, KB982331, KB220131, KB980376

    I keep reciving this code error 646 for my microsoft exel office, power point, the path of information, access, Word ect. Tried to update several times, but having the same error problem. I had windows to set up the problem with the troubleshooter, but it found no solution. Don't know what to do and do not see one having a problem with this particular codes...?  Help, please!

    Have you seen: http://social.answers.microsoft.com/Forums/en-US/vistawu/thread/18449f60-c149-4eaf-b8e6-a2880cd7232b TaurArian [MVP] 2005-2011-implementation to date of Services

Maybe you are looking for

  • I just downloaded Firefox and the command 'bookmark this page' does not appear in the bookmark icon.

    When I downloaded, I also choose to import IE Favorites and they all appeared. When I opened the bookmark icon, the "mark this page" command is missing, so I can't to bookmark a page. Everything else seems normal. It is an old computer running XP.

  • Pavilion of 500-118 usb controller driver

    I wish to install Windows 7 on a 500-118 Pavilion and can not find the driver for the Universal Serial Bus (USB) controller and it's why some USB ports do not work. Yes I realize that this operating system came with this system and there are no drive

  • Game Top Spin 2 ERROR 1402 could not open key

    I try to install the game Top Spin 2, but I have the problem with the Error 1402.Could not open key: UNKNOWN/components and more numbers. Any solution for Windows XP?

  • The RPC server is unavailable. How can I fix it?

    I have Windows XP SP3 and I try to install a Dell 964 all-in-one printer and every time it almost finished installing it stops and I get a message that says the server RPC is unavailable. How can I fix it? I don't know I asked this question in the ri

  • Third party UI for Windows Firewall

    Hello Wonder if anyone can confirm or otherwise allow or not an add on I guess that replace the component panel software snap-in MMC would be useful to be "Friendlier" in advanced security mode? Any opinions? The product I noticed is available in a f