「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: 右括弧がありません」というエラーが発生します