我正在使用包含“WHERE”子句中的“IF”语句的查询。但PL \ SQL Developer在执行时会出现一些错误。任何人都可以请帮助我正确的查询?以下是查询:如果在Where子句中的语句
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:invalid relational operator”。
配售括号status_flag = STATUS_ACTIVE
导致错误“ORA-00907:缺少右括号”
谢谢!这真的有帮助 – user2100620 2013-03-14 13:49:43
@DCookie,如何在IF语句中添加WHERE子句条件? – masT 2014-06-19 12:12:09
案例:'t.status = null'在t.status实际上为null的情况下不起作用。空很奇怪。 – defactodeity 2014-12-18 06:57:00