Skip to content
Advertisement

Case statement in where clause oracle

In where clause i have two option 1) status = ‘N’ and type = ‘1’ and 2) status = ‘Y’ and type = ‘1’ based on parameter I need execute one option:

  where 
     case 
        when (carName = :P_PARAMETER) then  status = 'N' and type = '1'
        else status = 'Y' and type = '1'
     end

After execute get error any solution for solve this problem or other method?

Advertisement

Answer

You need to rewrite the logic:

where type = '1'
  AND ((status = 'N' AND carName = :P_PARAMETER))
        OR status = 'Y')
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement