I get an error while writing the IIF stamtement, table and the statement given below,
Statement:
SELECT IIF(EMP_ID=1,'True','False') from Employee;
Error: 00907-missing right parantheses
CREATE TABLE SCOTT.EMPLOYEE
(
EMP_ID INTEGER NOT NULL,
EMP_FNAME VARCHAR2(30 BYTE) NOT NULL,
EMP_LNAME VARCHAR2(30 BYTE) NOT NULL,
EMP_ADDRESS VARCHAR2(50 BYTE) NOT NULL,
EMP_PHONE CHAR(10 BYTE) NOT NULL,
EMP_GENDER CHAR(1 BYTE)
)
Please provide your inputs.
Two other alternatives:
a combination of
NULLIF
andNVL2
. You can only use this ifemp_id
isNOT NULL
, which it is in your case:simple
CASE
expression (Mt. Schneiders used a so-called searchedCASE
expression)Oracle doesn't provide such IIF Function. Instead, try using one of the following alternatives:
DECODE Funciton:
CASE Function:
In PL/SQL, there is a trick to use the undocumented
OWA_UTIL.ITE
function.