View Single Post

   
  #3 (permalink)  
Old 02-28-2008, 11:29 AM
douggunnoe@gmail.com
 
Posts: n/a
Default Re: Preventing Negative values in table.

On Oct 31, 1:38 pm, nopam_pcart...@atlashosting.com wrote:
> Lets say I have a table:
>
> create table test(
> ID int unsigned default 0);
>
> If someone was to update the table with the following statment:
> UPDATE test SET ID = ID - 1
>
> And the ID in the field was 0, this would cause a large numeric value
> because it's an unsigned int,
> is there a way to prevent this from happening, in the form of some trigger
> or so.
>
> My goal is not to have these values in the table, if the result is going to
> cause invaild data, I want to somehow
> prevent this.
> Thanks
> -Paul C


Michael Fesser is correct.

However, I am wondering what would happen if you set ID to NULL
instead of 0. If someone then tried this, UPDATE test SET ID = ID - 1,
would that not generate an invalid data type error from the DB?

Reply With Quote