问题的情况

时间:2014-12-12 10:25:38

标签: sql oracle case toad case-when

我试图在我的SQL查询中使用一个简单的case语句,但它似乎不起作用。这是我的疑问:

     SELECT location_id, rtb_user_id, start_time, end_time, tt_no, assn_by,
       assn_time, loc_id, loc_name, parent_loc_id, hr_level, userid,
       firstname, lastname, pwd, email, empid, locationid, departmentid,
       designationid, enabled, login_name, user_roles, cell_no,
       reporting_to, theme_name, cmp_emp_id, cmp_alias, cmp_mail,
       cmp_phone, v.cust_id, v.cust_mob, v.mac_addr, v.email_id,
       CASE WHEN v.PROJ_ID = '10070' THEN
       (   'pid='
       || v.proj_id
       || CHR (38)
       || 'issuetype='
       || v.issue_id
       || CHR (38)
       || 'customfield_10233='
       || v.cust_id
       || CHR (38)
       || 'customfield_10014='
       || v.mac_addr
       || CHR (38)
       || 'customfield_10016='
       || v.cust_mob
       || CHR (38)
       || 'reporter='
       || v.email_id) as jira_url
       else
       (   'pid=' || v.proj_id
       || CHR (38)|| 'issuetype='
       || v.issue_id|| CHR (38)
       || 'customfield_10004='  || v.cust_id
       || CHR (38)  || 'customfield_10014='
       || v.mac_addr  || CHR (38) || 'customfield_10016='
       || v.cust_mob|| CHR (38)
       || 'reporter='|| v.email_id) as jira_url
       END   
  FROM rtb_visit_assn v, rtb_locations l, rtb_users u
 WHERE v.location_id = l.loc_id
   AND v.rtb_user_id = u.userid
   AND l.loc_id = u.locationid);

它会出现错误,例如"错过正确的副作用"或"缺少关键字"

1 个答案:

答案 0 :(得分:0)

您没有匹配括号,因此错误。计算(然后计算) - 他们需要匹配。

相关问题