> How do I go about doing this?
If you have a form field that is blank, you can do this:
<CFQUERY .... >
INSERT INTO foo
(name,age,zip)
VALUES
(
'#form.name#',
<CFIF trim(form.age) is "">
NULL,
<CFELSE>
#trim(form.age)#,
</CFIF>
<CFIF trim(form.zip) is "">
NULL,
<CFELSE>
'#trim(form.zip)#',
</CFIF>
)
</CFQUERY>
Or simply leave the columns to contain NULL out of the query. They will automatically
be set to NULL if they are defined to allow NULLs and they do not have a default value
defined.
> Is this a wise thing to do?
Yes. It is easy to search for (WHERE zip IS NULL) and CF will treat the value of the
column as an empty string so there is no worry about displaying a NULL value -- it'll
just be blank.
> Why doesn't SQL 7 automatically do that?
It will automatically fill a column with NULL if you do not specify the column in the
INSERT statement. Unless, of course, the column is defined as NOT NULL, in which case
an error will occur or the column has a default value defined.
Craig
> -----Original Message-----
> From: David Clay [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, March 01, 2001 12:34 PM
> To: CF-Talk
> Subject: NULLs
>
> I would like to insert a NULL value into a SQL 7 table if a field is not filled in.
>
> How do I go about doing this? Is this a wise thing to do? Why doesn't SQL 7
>automatically do that?
>
> Any help would be greatly appreciated. Thank you fro your time.
>
> Dave Clay
> Internet Facilitator
> Trus Joist, A Weyerhaeuser Business
> 5995 Greenwood Plaza Blvd, Suite 100
> Greenwood Village, CO 80111
> 303.770.8506
> 303.770.8506
>
>
>
>
>
>
>
>
>
>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists