When p_type is null, then I have to provide two values i.e ('value1','value2'). How can I achieve this using Case or Decode statement in where clause? Below PL/SQL block is not valid and throws an error of missing keyword: statement ignored.
Declare
l_xml CLOB;
p_type varchar2(200) := 'value1'; -- can be null
begin
SELECT XMLAGG (
XMLELEMENT ("Address",
(XMLFOREST (usg.code as "CODE",
usg.date as "Date"
)))) .getclobval()
into l_xml
FROM usg
WHERE usg.number = '12345'
AND usg.code = p_type
OR CASE WHEN p_type IS NULL THEN usg.code in ('value1','value2') END;
dbms_output.put_line (l_xml);
end;