Victor,

I don't think it matters so much. I personally like the second solution
better as it is just more readable and I think it will give you more
flexibility if you need it (structural flexibility, not logical
flexibility). 

On a personal note, what I would do is param the value to an integer,
perhaps Zero then just insert it no matter what. I have issues with the
use of NULLs in a database unless absolutely required:

http://www.bennadel.com/blog/85-Why-NULL-Values-Should-Not-Be-Used-in-a-
Database-Unless-Required.htm

But, that is just me and I don't know your particular situation. In my
experience though, I would rather work with ZERO than with NULL. Plus,
on the output, zero can be converted to a boolean, where as an empty
string cannot (the ColdFusion representation of a NULL value pulled out
of a query).

My 2 cents.

......................
Ben Nadel
Certified Advanced ColdFusion Developer
www.bennadel.com
 

-----Original Message-----
From: Victor Moore [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 27, 2006 11:51 AM
To: CF-Talk
Subject: Insert best practice

Hi,

I was wondering which one are best practices when doing a db
insert/update:
<cfqueryparam value="#lfield#" cfsqltype="CF_SQL_INTEGER"
null="#iif((filed eq ""), de("yes"), de("no"))#" />,

or
<cfif val (field) gt 0)>
         <cfqueryparam value="#lfield#" cfsqltype="CF_SQL_INTEGER" />
<cfelse>
       null
</cfif>

First one seems more compact but not sure the delay evaluation. I mean
for a couple a columns I guess it doesn't matter but for a big table it
may add up.
The second one looks more clear. At least for me

Thanks
Victor




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

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

Reply via email to