select *
from smgoods g
where g.storeloc in
(case :a
when - 1 then (select mx.id from smstorelocations mx)
else (select mx.id from smstorelocations mx where mx.id = :a)
end)
where ( g.storeloc=:a or :a=-1 )
where -1=-1