Can you just build your select as a string (using textmerge) and then execute using macro substitution? This way you would not need such complex logic.
>Hi all,
>
>I suspect I am shooting myself in the foot with this inefficient query.
>
>Tables:
>mtgloan - contains mortgage loan data
>
>mtgproperty - contains property/parcel data, 1-many relationship with loans. Loans can have several properties under them.
>
>mtgacctnum - contains taxing jurisdiction and parcel number information. 1-many to property. A property can have several taxing authorities hitting it.
>
>All tables have autoincrenting primary keys, with FK's in the child tables as indicated.
>
>These variables contain selection criteria coming from a web form.
>
> lcFromAccount = Upper(Request.Form("From_Account"))
> lcToAccount = Upper(Request.Form("To_Account"))
> lcContract = Upper(Request.Form("Contract"))
> lcAddress = Upper(Request.Form("Address"))
> lcName = Upper(Request.Form("Borrowername"))
> lcParcel = Upper(Request.Form("Parcel"))
> lcCounty = Upper(Request.Form("County"))
> lcSt = Upper(Request.Form("State"))
> lcCollector = Upper(Request.Form("Collector"))
> lcBranch = Upper(Request.Form("Branch"))
>
>
>
>Here is the query itself. I suspect that I'm overdoing it on the trimming etc. But, it strikes me that this is the equivalent of doing a huge join before applying the selection filters, so this takes a good bit of work to run. Running time scales up poorly as the result set size increases. Thoughts are welcome.
>
>thanks,
>
If it's not broken, fix it until it is.
My Blog