')'附近的语法不正确。我该怎么解决?

时间:2018-01-16 05:02:21

标签: oracle-sqldeveloper

SELECT
    obj.obj_id obj_id,
    obj.obj_nm obj_nm,
    objsecu.usr_id usr_id,
    objsecu.email_id email_id,
    dbo.NVL(objprop.prop_val,'MM/DD/YYYY') prop_val
FROM
    od_mdv_actual_obj obj,
    od_md_objsecu objsecu,
    od_mdv_objprop objprop
WHERE
    obj.obj_id = objsecu.obj_id
    AND   obj.clnt_id = objsecu.clnt_id
    AND   obj.proj_id = objsecu.proj_id
    AND   obj.schm_id = objsecu.schm_id
    AND   obj.obj_id = objprop.obj_id (+)
    AND   obj.clnt_id = objprop.clnt_id (+)
    AND   obj.proj_id = objprop.proj_id (+)
    AND   obj.schm_id = objprop.schm_id (+)
    AND   2007 = objprop.prop_id (+)
    AND   obj.clnt_id =1
    AND   obj.proj_id =1
    AND   obj.schm_id =1
    AND   obj.obj_id IN (
        SELECT
            obj_depn_id
        FROM
            od_md_objrel
        WHERE
            rel_typ_id = 19
            AND   clnt_id =1
            AND   proj_id =1
            AND   schm_id =1
    );

我正在尝试使用上面的查询获取用户列表dbo.NVL失败并显示错误为“附近的语法不正确”)。“如何解决?请帮帮我

2 个答案:

答案 0 :(得分:1)

由于(+)符号,您收到错误。

AND   obj.obj_id = objprop.obj_id (+)
AND   obj.clnt_id = objprop.clnt_id (+)
AND   obj.proj_id = objprop.proj_id (+)
AND   obj.schm_id = objprop.schm_id (+)
AND   2007 = objprop.prop_id (+)

删除(+),它会正常工作。

答案 1 :(得分:0)

根据评论,您正在寻找左加入..

SELECT
    obj.obj_id obj_id,
    obj.obj_nm obj_nm,
    objsecu.usr_id usr_id,
    objsecu.email_id email_id,
    dbo.NVL(objprop.prop_val,'MM/DD/YYYY') prop_val
FROM od_mdv_actual_obj obj 
    left join od_md_objsecu objsecu on   obj.obj_id = objsecu.obj_id
        AND   obj.clnt_id = objsecu.clnt_id
        AND   obj.proj_id = objsecu.proj_id
        AND   obj.schm_id = objsecu.schm_id
    left join od_mdv_objprop objprop on   obj.obj_id = objprop.obj_id  
        AND   obj.clnt_id = objprop.clnt_id 
        AND   obj.proj_id = objprop.proj_id 
        AND   obj.schm_id = objprop.schm_id 
WHERE   objprop.prop_id =2007 
    AND   obj.clnt_id =1
    AND   obj.proj_id =1
    AND   obj.schm_id =1
    AND   obj.obj_id IN (
        SELECT
            obj_depn_id
        FROM
            od_md_objrel
        WHERE
            rel_typ_id = 19
            AND   clnt_id =1
            AND   proj_id =1
            AND   schm_id =1
    );