This is a discussion on numerical range within the MySQL General forum forums, part of the MySQL category; --> Is it possible to restrict the range that can be put in a floating point, or other data type ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Is it possible to restrict the range that can be put in a floating point, or other data type that allows decimal numbers. The data being stored will be that of the result of chemical analysis. The result could very well be 2.41however it would never be 24.1 so i want to ensure that a simple typo like this is caught. the context i am using this in would make validation at the front end very difficult so i would like to use the tables definition to error on the insert rather than except a value that is out of a realistic range. Thanks, Chris |
| ||||
| You could use triggers to check for sane values on fields and rollback if not sane. http://dev.mysql.com/doc/refman/5.0/en/triggers.html You'd need to handle the rollback in your frontend app. Dan On 12/8/06, Christian High <cjhigh@gmail.com> wrote: > Is it possible to restrict the range that can be put in a floating point, or > other data type that allows decimal numbers. The data being stored will be > that of the result of chemical analysis. The result could very well be > 2.41however it would never be > 24.1 so i want to ensure that a simple typo like this is caught. the context > i am using this in would make validation at the front end very difficult so > i would like to use the tables definition to error on the insert rather than > except a value that is out of a realistic range. > > Thanks, > > Chris > > |