select statement with multiple inputs
I want to create a stored procedure that takes in two params. One param will occisionally be null in which case I dont want it to be used in the where clause. so for example if two parameters are used contestid and status. I want to be able to grab all items where the contestid matchs but status does not matter. but other times it the status is provided or not null I want it to be included in the where. pseudo code
if p_status = null then
where contestid = p_contestid
else
where contestid = p_contestid and status = p_status
if p_status = null then
where contestid = p_contestid
else
where contestid = p_contestid and status = p_status
0