[ic] Table::DBI set_slice and undefined values

interchange-users@interchange.redhat.com interchange-users@interchange.redhat.com
Thu May 16 10:21:00 2002


On Thu, May 16, 2002 at 09:50:16AM -0400, Bill Carr wrote:
> In an effort to optimize MySQL I have added NOT NULL DEFAULT <some
> value> to most of my column definitions. According to the Mysql manual
> this will result in a smaller data file size and make everything faster.
> 
> Now when I insert a row using mv_todo=set I receive an error message:
> column can not be NULL.
> 
> If I INSERT using the mysql command line any missing fields will be will
> contain the DEFAULT values from their column definitions.
> 
> Using IC to insert into a database Interchange will make an insert like
> this:
> 	insert into <table_name> (a,b,c) VALUES ('defined value',undef,undef)
> 
> How can I get it to do this instead
> 	insert into <table_name> (a) VALUES ('defined value')

It is probably safer if you provide the values.  It gets really slippery
otherwise to know what undefined values one wants and which one does
not want.


for(columns_in_my_table) {
  $v->{$_}||='';
  }

where $v is a hashref for that record. 

Be careful, though, some of your perl might respond differently to ''
than to NULL undef.

--

Are you sure this improves speed?  Yes, absolutely if the columns are
not indexed and an index will help.  But as a rule I'd be surprised.


> 
> This will let the insert happen without error and the undefined columns
> will get set with the default from their col defs.
> 
> -- 
> Bill Carr
> Worldwide Impact
> bill@worldwideimpact.com
> 413-253-6700
> 
> _______________________________________________
> interchange-users mailing list
> interchange-users@interchange.redhat.com
> http://interchange.redhat.com/mailman/listinfo/interchange-users

-- 

Christopher F. Miller, Publisher                               cfm@maine.com
MaineStreet Communications, Inc           208 Portland Road, Gray, ME  04039
1.207.657.5078                                         http://www.maine.com/
Content/site management, online commerce, internet integration, Debian linux