I have an employee table from which I retrieve records using a stored procedure now I need to add a condition in the stored procedure --
Only if employeeType='MD' then check if employeeReportableIndicator='N' , if 'N' then do not fetch this record.
This implicitly means --
1)if employeeType!='MD' then I should fetch the record regardless of employeeReportableIndicator column value .
2)if employeeType='MD' and employeeReportableIndicator='Y' fetch the value .
To simplify the stored procedure I am just writing a small query covering the above condition .Here is what I tried till now
select *
from employee
where somecondition1
and somecondition2
and CASE when employeeType='MD'
then (CASE when employeeReportableIndicator='N'
then false
else true
END)
END
The above is giving me syntax error
an unexpected token "END-OF-STATEMENT" was found following "else true END ) END".Expected token may include: "".SQLSTATE=42601
Also is my approach for writing the query correct ,please suggest if any better solution. I am using DB2 and Sybase