【发布时间】:2013-03-02 00:45:15
【问题描述】:
我正在处理一个在“WHERE”子句中包含“IF”语句的查询。但是 PL\SQL Developer 在执行时给出了一些错误。谁能帮我正确查询?这是查询:
SELECT t.first_name,
t.last_name,
t.employid,
t.status
FROM employeetable t
WHERE IF status_flag = STATUS_ACTIVE then t.status = 'A'
IF status_flag = STATUS_INACTIVE then t.status = 'T'
IF source_flag = SOURCE_FUNCTION then t.business_unit = 'production'
IF source_flag = SOURCE_USER then t.business_unit = 'users'
AND t.first_name LIKE firstname
AND t.last_name LIKE lastname
AND t.employid LIKE employeeid;
我收到错误“ORA-00920:无效的关系运算符”。
在status_flag = STATUS_ACTIVE 周围放置括号会导致错误“ORA-00907:缺少右括号”
【问题讨论】:
标签: oracle plsql plsqldeveloper