Subject | Possible to write this in a way that indices will be used |
---|---|
Author | Maya Opperman |
Post date | 2008-05-15T14:10:59Z |
Hi,
I have a query written as follows:
select blah..,
from MyTable D
where ((D.SuplCde = :ISupplierCode) or (:ISupplierCode is null))
and ((D.WrhseCde = :IWarehouseCode) or (:IWarehouseCode is null))
and ((D.StkCde = :IStockCode) or (:IStockCode is null))
and ((D.IsActve = 'Y') or (:IIncludeInactive = 'Y'))
Is there any elegant way that I can rewrite this so that it will make
use of indexes, but without me having repeat vast volumes of code over
and over?
Thanks
Maya
I have a query written as follows:
select blah..,
from MyTable D
where ((D.SuplCde = :ISupplierCode) or (:ISupplierCode is null))
and ((D.WrhseCde = :IWarehouseCode) or (:IWarehouseCode is null))
and ((D.StkCde = :IStockCode) or (:IStockCode is null))
and ((D.IsActve = 'Y') or (:IIncludeInactive = 'Y'))
Is there any elegant way that I can rewrite this so that it will make
use of indexes, but without me having repeat vast volumes of code over
and over?
Thanks
Maya