Is there a better way to write this query in a plpgsql function than almost duplicating the query twice? Any way to say if valB is null then it should match anything in colB, essentially being removed from the where clause?
if (valB is not null) then
update mytable set colA = valA where (colB, colC) = (valB, valC);
else
update mytable set colA = valA where (colC) = (valC);
end if;