简体   繁体   中英

Getting' ORA-01427: single-row subquery returns more than one row' Error

When I try to execute this code without the case and just as ...and TRANSFORMER IN(SELECT REGEXP_SUBSTR...) it works. however adding the case to grab everything if TID is NULL gives me the error..

(select t.DAY_DATE as D, t.*  from pplco_transformer_kva t where 

--NORMALLY '03-MAR-14' IS A VARIABLE
 DAY_DATE = TO_DATE('03-MAR-14')and TRANSFORMER IN(

  --NORMALLY '26113S36753,25761S36662' IS A VARIABLE
  CASE WHEN '26113S36753,25761S36662' IS NULL THEN(

    (t.TRANSFORMER)

  )ELSE(
    SELECT REGEXP_SUBSTR('26113S36753,25761S36662', '[^,]+', 1,LEVEL) 
    FROM DUAL CONNECT BY 
    regexp_substr('26113S36753,25761S36662', '[^,]+', 1, level) is  
    not null)
  END
  )
 );

The case statement doesn't return a list of variables. Nor, does the first part do what you think. The following is the logic that I think you want:

where DAY_DATE = TO_DATE('03-MAR-14') and
      ('26113S36753,25761S36662' IS NULL OR
       '26113S36753,25761S36662' IS NOT NULL AND
       t.TRANSFORMER IN (SELECT REGEXP_SUBSTR('26113S36753,25761S36662', '[^,]+', 1,LEVEL) 
                         FROM DUAL CONNECT BY 
                         regexp_substr('26113S36753,25761S36662', '[^,]+', 1, level) is not null
                        )
      )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM