I have this query that works in Oracle but I want to convert it to use Coalesce because of some problems I'm having with Visual Studio.
SELECT *
FROM a Left Join b on b.institution_code=a.institution_code
WHERE
(upper(a.Login_Name)=UPPER('%' || :Login_Name || '%') OR :Login_Name IS NULL)
AND (upper(a.Display_Name) Like UPPER('%' || :Display_Name || '%') OR :Display_Name IS NULL)
AND (upper(a.Email_Address)=UPPER(:Email_Address) OR :Email_Address IS NULL)
AND ((a.institution_code=:institution_code) OR :institution_code IS NULL)
AND (upper(b.institution_desc) Like UPPER('%' || :institution_desc || '%') OR :institution_desc IS NULL)
This works
WHERE
Upper(a.Display_Name) LIKE Upper('%' || COALESCE(:Display_Name,a.Display_Name) || '%')
AND upper(a.Login_Name)=Upper(COALESCE(:Login_Name,a.Login_Name))
AND upper(a.Email_Address)=Upper(COALESCE(:Email_Address,a.Email_Address))
but when I try to convert the institution_code and institution_desc field to use coalesce i don't get any results from the queries.
when i add these lines there are no results
AND a.institution_code=COALESCE(:institution_code,a.institution_code)
AND (Upper(b.institution_desc) LIKE Upper('%' || COALESCE(:institution_desc,b.institution_desc) || '%'))