错误的查询嵌套选择错误ORA-00913

时间:2012-11-16 08:08:07

标签: sql oracle plsql ora-00913

它不起作用,我只得到错误ORA-00913:“太多的值。”

问题我认为是嵌套选择。我想用这个选择来查看。

此代码显示所有员工的报告。我更改了这篇文章的属性名称:

 SELECT sk."AAAA", sk."BBBB", sk."CCCC", sk."DDD",
          sk."EEEE", sk."FFFF", sk."GGGGG",
          sk."HHHHH",
          (SELECT f.VALUE
           FROM fnd_user_property_tab f
           WHERE f.identity = sk.login
           AND NAME = 'IIIII') iii,sk."JJJJ",

           (SELECT f.VALUE
           FROM fnd_user_property_tab f
           WHERE f.identity = sk.login
           AND NAME = 'SMTP_MAIL_ADDRESS') mail,

           (SELECT f.VALUE
            FROM fnd_user_property_tab f
            WHERE f.identity = sk.login 
            AND NAME = 'KKKK') kkkk,

            (SELECT fnd.ORACLE_ROLE
             FROM fnd_user_role_tab fnd
             WHERE fnd.identity = sk.login
             AND fnd.ORACLE_ROLE LIKE 'STH-%') profil,

             (SELECT dr.ROLE, sox_co_w_roli(dr.role) skład
              FROM sys.dba_roles dr
              WHERE dr.role = (SELECT fnd.ORACLE_ROLE
                              FROM fnd_user_role_tab fnd
                              WHERE fnd.identity = sk.login  
                              AND fnd.ORACLE_ROLE LIKE 'STH-%')
             ) profile_role
    FROM sox_konta sk
    WHERE("PROFIL_DB" LIKE '%ppppp%'
          OR "PROFIL_DB" = 'oooooooo'
          OR "PROFIL_DB" = 'rrrrrrrr'
          )
    AND "COMPANIES" IN ('ZZ; ', 'YY; ')

2 个答案:

答案 0 :(得分:2)

尝试以这种方式重写您的选择

SELECT sk."AAAA", sk."BBBB", sk."CCCC", sk."DDD",
          sk."EEEE", sk."FFFF", sk."GGGGG",
          sk."HHHHH",
          f_iii.value iii, sk."JJJ",
          f_mail.value mail,
          f_kkk.value kkk,
          fnd.oracle_role profil,
          dr.ROLE, sox_co_w_roli(dr.role) skład
    FROM sox_konta sk,
         fnd_user_property_tab f_iii,
         fnd_user_property_tab f_mail,
         fnd_user_property_tab f_kkk,
         fnd_user_role_tab fnd,
         sys.dba_roles dr
    WHERE("PROFIL_DB" LIKE '%ppppp%'
          OR "PROFIL_DB" = 'oooooooo'
          OR "PROFIL_DB" = 'rrrrrrrr'
          )
        AND "COMPANIES" IN ('ZZ; ', 'YY; ')
        AND f_iii.identity = sk.login
        AND f_iii.NAME = 'IIIII'
        AND f_mail.identity = sk.login
        AND f_mail.NAME = 'SMTP_MAIL_ADDRESS'
        AND f_kkk.identity = sk.login
        AND f_kkk.NAME = 'KKKK'
        AND fnd.identity = sk.login
        AND fnd.ORACLE_ROLE LIKE 'STH-%'
        AND dr.role = fnd.ORACLE_ROLE;

我认为这会有所帮助。

答案 1 :(得分:1)

从这篇文章开始。你收到错误了吗?是?您需要更改为 iii 提供值的子查询,以便它只返回一行。

如果此段未返回错误,则添加下一段,直到找出导致错误的原因。

SELECT sk."AAAA", sk."BBBB", sk."CCCC", sk."DDD",
      sk."EEEE", sk."FFFF", sk."GGGGG",
      sk."HHHHH",
      (SELECT f.VALUE
       FROM fnd_user_property_tab f
       WHERE f.identity = sk.login
       AND NAME = 'IIIII') iii
FROM sox_konta sk
WHERE("PROFIL_DB" LIKE '%ppppp%'
      OR "PROFIL_DB" = 'oooooooo'
      OR "PROFIL_DB" = 'rrrrrrrr'
      )
AND "COMPANIES" IN ('ZZ; ', 'YY; ')