无法解析查询,请检查查询的语法。 (ORA-00905:缺少关键字)

时间:2015-03-16 14:43:29

标签: mysql oracle oracle-apex

尝试使用以下sql查询创建交互式报告。得到标题中提到的错误。

SELECT 
  FIRST_NAME||' '||LAST_NAME "USERNAME" 
FROM 
  USERS 
WHERE 
  USERNAME IN (
    select 
      username 
    from 
      users 
    where 
      username not in (
        Select 
          accessed_by 
        from 
          temp_amal
        where 
          access_date >= :P2610_DATE_FROM
          and access_date <= :P2610_DATE_TO
          and (CASE :P2610_RADIO
            when 'F' then col1='F'
          end)
      )
  )
order by 1;

1 个答案:

答案 0 :(得分:1)

WHERE条件的两个操作数不能位于CASE中。只是其中一个。

SELECT FIRST_NAME||' '||LAST_NAME "USERNAME" FROM USERS WHERE USERNAME 
IN
(select username from users 
where username not in 
(Select accessed_by from temp_amal
where access_date >= :P2610_DATE_FROM
and access_date <= :P2610_DATE_TO
and col1 = (CASE :P2610_RADIO
            when 'F' then 'F'
            end)
))
order by 1;

所以,如果你想让你的查询更具动态性。您必须生成动态SQL查询。