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
Cfqueryparam allows to to specify that NULL values are allowed anyway, so
you don't need to do that check.
Russ
-Original Message-
From: Victor Moore [mailto:[EMAIL PROTECTED]
Sent: 27 September 2006 16:51
To: CF-Talk
Subject: Insert best practice
Hi,
I was wondering which one are
You might try using YesNoFormat() rather than IIF(). Just remember to
NOT the result if the expression calls for it.
null=NOT yesNoFormat(expression)...
M!ke
-Original Message-
From: Victor Moore [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 27, 2006 10:51 AM
To: CF-Talk
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
Thanks all.
I think I will stick with the second one. Maybe more typing but it's
cleaner.
Cheers
Victor
~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your
and it put
null in the database, not my value.
Steve.
-Original Message-
From: COLLIE David [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 27, 2006 12:03 PM
To: CF-Talk
Subject: RE: Insert best practice
I was wondering which one are best practices when doing a db
insert
Cfqueryparam allows to to specify that NULL values are
allowed anyway, so you don't need to do that check.
Can you explain what you mean? ColdFusion has no concept of null. The
NULL attribute, if set to 'YES' means that CFQUERYPARAM ignores the
value in the VALUE attribute and passed the
If you are using MS SQL Server, create a stored proc and let the null
handlers like isNull() and nullIF() handle these for you.
A friend of mine showed me this little trick:
select
column
from
table
where
IsNull(ID,'') = IsNull(NullIf(@ID,''),IsNull(ID,''))
This allows you to create
:[EMAIL PROTECTED]
Sent: 27 September 2006 17:22
To: CF-Talk
Subject: RE: Insert best practice
Cfqueryparam allows to to specify that NULL values are allowed anyway,
so you don't need to do that check.
Can you explain what you mean? ColdFusion has no concept of null. The NULL
attribute, if set
I have always used
cfqueryparam
cfsqltype=CF_SQL_VARCHAR
value=#form.fieldname#
null=#YesNoFormat(not Len(form.fieldname))#
You guys are saying the null parameter is not necessary? Wouldn't
that insert an empty string rather than a null?
--
[EMAIL PROTECTED]
Janitor,
10 matches
Mail list logo