Ah, sorry, didn't explain fully. I did a StructKeyExists and a Len to make
sure that the field you are going to evaluate really exists in the form. If
it doesn't, you don't want your cfquery to throw a gnarly error (most
likely) so if the assertion is false, the WHERE clause becomes WHERE 1 = 0
which is always false so the query completes and returns 0 records.
Alternatively, you could wrap your query in a try/catch and catch any db
errors and display them back to the user telling them that they forgot to
put in a field to search on.

Cheers,
Judah

On Wed, Sep 10, 2008 at 10:12 AM, David Moore, Jr. <[EMAIL PROTECTED]>wrote:

> Judah wrote:> Untested but should work:> > <cfquery
> name="getPhysicianRecords" datasource="#DSN#">> SELECT * FROM Contacts>
> WHERE Contacts.ContactType = 'Physician'> <cfif Len(form.field) AND
> StructKeyExists(form,form.field)>> AND Contacts.#FORM.Field# =
> '#Trim(form[form.field])#'> <cfelse>> 1 = 0> </cfelse>> ORDER BY
> Contacts.LastName> </cfquery>
> Showing my ignorance again, but it is already showing so why not. What does
> the
>
> 1 = 0 do?
>
> ~David
> _________________________________________________________________
> Want to do more with Windows Live? Learn "10 hidden secrets" from Jamie.
>
> http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_domore_092008<http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns%21550F681DAD532637%215295.entry?ocid=TXT_TAGLM_WL_domore_092008>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312342
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to