简体   繁体   English

ORA-01427:单行子查询返回的更新不只一行

[英]ORA-01427: single-row subquery returns more than one row with update

I have an update statement, at first it worked with some data, but after a while I've been having issues with some regiters , I got the following error: ORA-01427: single-row subquery returns more than one row . 我有一条update语句,起初它可以处理一些数据,但是过了一段时间,我在某些regiters上遇到了问题,我遇到了以下错误: ORA-01427:单行子查询返回的行多 I thought it was the IN because the query might return repeated IDs, so I put a DISTINCT but I kept getting the same error, does anyone have any idea what could it be? 我以为这是IN,因为查询可能返回重复的ID,所以我放了DISTINCT但我一直遇到相同的错误,有人知道这是什么吗?

The query below: 下面的查询:

 UPDATE 
        TABLE_DETAIL DET 
    SET 
        DET.ACCEPTED=?,
        DET.VALUE_ACCEPTED=(SELECT RES.VALUE FROM TABLE_RES RES WHERE RES.MYT=DET.MYT AND RES.RAD=DET.RAD AND RES.ITEM=DET.ITEM), 
    WHERE 
        DET.ID 
    IN (
        SELECT 
            DISTINCT DET_I.ID
            FROM TABLE_DETAIL DET_I, TABLE_RES RES_I, TABLE_REC REC 
            WHERE 
                DET_I.MYT = ? 
            AND 
                REC.TEMP 
                NOT IN (
                    SELECT DISTINCT TEMP 
                    FROM 
                    TABLE_IMAGES WHERE CODE=?) 
            AND RES_I.USER = ? 
        )

You don't need SELECT DISTINCT with IN . 您不需要使用IN SELECT DISTINCT

The proximal cause of your problem is this code: 您的问题的近端原因是此代码:

    DET.VALUE_ACCEPTED = (SELECT RES.VALUE FROM TABLE_RES RES WHERE RES.MYT=DET.MYT AND RES.RAD=DET.RAD AND RES.ITEM=DET.ITEM), 

It isn't really possible to say how to fix it. 真的不可能说出如何解决它。 The error code seems pretty clear: More than one row is returned by this query. 错误代码看起来很清楚:此查询返回了多个行。

You can add WHERE rownum = 1 if you want an arbitrary value. 如果需要任意值,可以添加WHERE rownum = 1 Or an aggregation function in the SELECT . SELECT的聚合函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ORA-01427:单行子查询在Update Statement中返回多行 - ORA-01427: single-row subquery returns more than one row in Update Statement 如何修复 Ora-01427 单行子查询在 Update 语句中返回多行? - How to fix Ora-01427 single-row subquery returns more than one row in Update statement? SQL UPDATE ORA-01427:单行子查询返回多于一行计算百分比 - SQL UPDATE ORA-01427: single-row subquery returns more than one row calculating percentage 错误的ORA-01427:单行子查询返回多个行 - Erroneous ORA-01427: single-row subquery returns more than one row 如何修复ORA-01427:单行子查询返回的行多? - How can I fix ORA-01427: single-row subquery returns more than one row? ORA-01427:单行子查询返回多行-问题 - ORA-01427: single-row subquery returns more than one row - issue ORA-01427:单行子查询返回多行-需要多个值 - ORA-01427: single-row subquery returns more than one row- multiple values needed ORA-01427:当使用SELECT COUNT时,单行子查询返回多行 - ORA-01427: single-row subquery returns more than one row ,,WHEN USING SELECT COUNT 如何修复ORA-01427:单行子查询返回的行多 - How do I fix ORA-01427: single-row subquery returns more than one row ORA-01427:单行子查询返回多行-如何解决? - ORA-01427:single-row subquery returns more than one row - how to fix?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM