0

我的查询如下:

SELECT DISTINCT * 
FROM (SELECT depts."ID", depts.arabic_description 
      FROM sng_v_org_unit_departments depts 
      INNER JOIN (SELECT "ID", arabic_description, ouh_id   
                  FROM sng_v_org_unit_headers 
                  START WITH "ID" = 
                  (SELECT headid 
                   FROM emppirmesion per 
                   inner join  empldabdetail empinfo 
                           on per.emprecid = empinfo.recid 
                   where lower(empinfo.shortname) =  lower('ibmadmin') and 
                         per.headid > 0 and 
                         per.clasisymbolicname = 'SoHiring') 
                  CONNECT BY PRIOR "ID" = ouh_id) heads 
      ON depts.ouh_id = heads."ID"
      UNION 
      SELECT per.depid, depts.arabic_description 
      FROM emppirmesion per 
      inner join empldabdetail empinfo on per.emprecid = empinfo.recid 
      inner join sng_v_org_unit_departments depts on per.depid = depts."ID" 
      where lower(empinfo.shortname) = lower('ibmadmin') and 
            per.depid > 0 and 
            per.clasisymbolicname = 'SoHiring')

我收到异常ORA-01427:如果我在 emppirmesion 中有不止一行具有相同的 clasisymbolicname 尽管它们具有不同的 headid 值并且在这种情况下不应发生此异常,则单行子查询返回多行,请就此提出建议。

4

1 回答 1

0

问题是 START WITH 需要单个值,而我的子查询返回多个值,所以我将查询

START WITH "ID" = 
                  (SELECT headid 
                   FROM emppirmesion per 
                   inner join  empldabdetail empinfo 
                           on per.emprecid = empinfo.recid 
                   where lower(empinfo.shortname) =  lower('ibmadmin') and 
                         per.headid > 0 and 
                         per.clasisymbolicname = 'SoHiring')

Where "ID" in 
                  (SELECT headid 
                   FROM emppirmesion per 
                   inner join  empldabdetail empinfo 
                           on per.emprecid = empinfo.recid 
                   where lower(empinfo.shortname) =  lower('ibmadmin') and 
                         per.headid > 0 and 
                     per.clasisymbolicname = 'SoHiring') 

它工作正常。

于 2013-07-08T09:04:49.750 回答