MappingSqlQuery : One Parameter used Multiple Times?
After looking through the docs, I believe the answer to this queston is "no". I figured I would make sure this conclusion was not incorrect.
I have some SQL statements which are being executed using MappingQuery. Some of these SQL statement join a handful of tables, many of which have historical data which have an effective and a term date. Something like the following is not uncommon.
Both of these parameters are actually supplied the same value; a single date which is passed in. At times, there may be half a dozen dates which are being compared; meaning the same date value may be used in 12 different parameters. That requires declaring the parameter 12 times, and then supplying it 12 times when the query is executed.
AND b.PARTC_ADDR_EFF_DATE <= ?
AND b.PARTC_ADDR_TERM_DATE >= ?
I started to look at using named parameters to make this easier to manage; but it seems that I still need to declare and supply the date value 12 times. The only benefit named parameters seems to offer is that the order in which parameters are declared is no longer important. The following doesn't seem possible:
Where I can then declare 1 parameter of type TIMESTAMP which is then used for all isntances of :effDate in the SQL statement. Is that correct?
AND b.EFF_DATE <= :effDate
AND b.TERM_DATE >= :effDate
AND c.EFF_DATE <= :effDate
AND c.TERM_DATE >= :effDate
AND d.PARTC_ADDR_EFF_DATE <= :effDate
AND d.PARTC_ADDR_TERM_DATE >= :effDate