Subject RE: [firebird-support] Possible to write this in a way that indices will be used
Author Rick Debay
Selectable stored procedure that assembles the statement based on what
parameters are NULL or not. Or if the fields are defined as NOT NULL,
then the NOT DISTINCT comparison would work.

-----Original Message-----
[] On Behalf Of Maya Opperman
Sent: Thursday, May 15, 2008 10:11 AM
Subject: [firebird-support] Possible to write this in a way that indices
will be used


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?




Visit and click the Resources item on the
main (top) menu. Try Knowledgebase and FAQ links !

Also search the knowledgebases at

Yahoo! Groups Links

Disclaimer: This message (including attachments) is confidential and may be privileged. If you have received it by mistake please notify the sender by return e-mail and delete this message from your system. Any unauthorized use or dissemination of this message in whole or in part is strictly prohibited. Please note that e-mails are susceptible to change. RxStrategies, Inc. shall not be liable for the improper or incomplete transmission of the information contained in this communication or for any delay in its receipt or damage to your system. RxStrategies, Inc. does not guarantee that the integrity of this communication has been maintained nor that this communication is free from viruses, interceptions or interference.