Re: inserted value != actual value in database

[prev] [thread] [next] [Date index for 2005/02/10]

From: Matt S Trout
Subject: Re: inserted value != actual value in database
Date: 00:22 on 10 Feb 2005
On Wed, Feb 09, 2005 at 12:48:14PM -0800, Emile Aben wrote:
> I have a problem with inserting data via CDBI with a mysql (3.23.38)
> backend in that I currently have no clue if a value I insert is the
> same as the value that is actually in the database. Say, I hit the
> maximum of an INT value, or the maximum length for a VARCHAR, mysql
> just inserts a value that is different from the value I asked it to
> insert. What I'd like to have is at least some kind of warning if one
> or more values I've inserted 'overflows' the column data-type.
> 
> Has anybody dealt with this type of overflow checking before? I see at
> least these options:
> - some mysql/DBI thing I haven't seen that returns a warning/error if
> this situation happens
> - adding constraints on all columns in a CDBI-object (maybe do this
> automatically)
> - manual checking of every before and after value

Consider before_create and before_update triggers, and look at the data on
the mysql-specific CPAN modules (Class::DBI::mysql et. al.)

        -- 
            Matt S Trout            Brag sheet:    http://trout.me.uk/services.html
LAMP, Infrastructure        Contact:       services@xxxxx.xx.xx
   and Automation
     specialist                                       Do it once. Do it right.

inserted value != actual value in database
Emile Aben 20:48 on 09 Feb 2005

Re: inserted value != actual value in database
Matt S Trout 00:22 on 10 Feb 2005

Re: inserted value != actual value in database
Tony Bowden 07:57 on 10 Feb 2005

Re: inserted value != actual value in database
Emile Aben 18:17 on 11 Feb 2005

Generated at 17:31 on 15 Feb 2005 by mariachi v0.52