Hi guys,
I tried both ways. neither work. They both come up with errors when your
updating the field with a quote mark in the desc or title. The page is in
a .cfc But I'm running out of options. Think I will try pulling out the
queries and put them into a normal .cfm page.
Also tried the ODBC connection thingo...made no difference.
I'll keep plugin away.
Jeremy
> IF the problem is that you're getting errors when there is no value
> for #JobDesc# you could handle that one of two ways:
>
> [A] ensure there is always a value of some kind, by setting a default
> value for it - perhaps a space. You can do that by using <cfparam
> name="JobDesc" default = " "> just before your <cfquery that does the
> insert.
>
> [B] conditionally update the JobOrderDesc field, only if there's a
> value for JobDesc. So you'd have something like this in your CFQUERY:
>
> UPDATE tbl_JobOrder
> SET JobTitle = '#JobTitle#'
> <cfif IsDefined("JobDesc")>,
> JobOrderDesc = '#JobDesc#'
> </cfif>
>
> (Note where the comma goes - you only want the comma at the end of the
> JobTitle line if there's a line following it)
>
> This is better than two queries, because it does the whole job in one
> call on the database. More efficient that way. Turn debugging on
> and have a look at the processing time for the page the way you are
> doing it compared to this way. It might only make milliseconds
> difference, but add a millisecond here and another there, and pretty
> soon you can reap significant performance savings.
>
> Cheers
> Mike Kear
> Windsor, NSW, Australia
> (who answered this yesterday but no one noticed apparently, apart from
> Kym Kovan who stole my idea yet again. Oftentimes Kym steals my ideas
> even before I think of them!)
> Certified Advanced ColdFusion Developer
> AFP Webworks
> http://afpwebworks.com
> ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month
>
>
>
>
> On Thu, 17 Feb 2005 10:52:21 +1100, Chad <[EMAIL PROTECTED]> wrote:
> > Be interested in best practice for testing for variables, I know there
> > is a better way, but most of my updates look like:
> >
> > --------------------------------------------------
> > <cfset Disp1 = 0>
> >
> > <cfif isdefined("JobDesc")>
> > <cfif JobDesc NEQ "">
> > <cfset Dips1 = 1>
> > </cfif>
> > </cfif>
> >
> > UPDATE tbl_JobOrder
> > SET JobTitle = '#JobTitle#'
> > <cfif Disp1 EQ 1>, JobOrderDesc = '#JobDesc#'</cfif>
> > --------------------------------------------------
> >
> > And as far as the PreserveSingleQuotes, I only had to use it when I did
> > things like:
> >
> > --------------------------------------------------
> > <cfset SQLWhere = " AND JobOrderDesc = '" & MyPassedString & "'">
> >
> > UPDATE tbl_JobOrder
> > SET JobTitle = '#JobTitle#'
> > #PreserveSingleQuotes(SQLWhere)#
> > --------------------------------------------------
> >
> > Chad
---
You are currently subscribed to cfaussie as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/