List:General Discussion« Previous MessageNext Message »
From:Bill Marrs Date:March 20 2001 6:48pm
Subject:RE: Second Request - Limit Filed Input
View as plain text  
At 11:22 AM 3/20/2001 -0500, Ravi Raman wrote:
>You can use an ENUM column type assuming the numerical range is less than
>65535 numbers.
>
>http://www.mysql.com/doc/E/N/ENUM.html

One problem I've seen with enums is that I end up with a blank ('') field 
if I try to insert a row with a value in the enum column that doesn't fit.

Is there a way to get the insert to fail on "bad input" instead?

For example:

mysql> CREATE TABLE Stats (
     ->   Status enum('good','bad') NOT NULL
     -> );
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO Stats VALUES ('neither');
Query OK, 1 row affected (0.00 sec)

(Can I get this insert to FAIL instead? because...)

mysql> select * FROM Stats;
+--------+
| Status |
+--------+
|        |
+--------+
1 row in set (0.01 sec)

(this isn't always a good thing).

-bill

Thread
Second Request - Limit Filed Inputdboothe20 Mar
  • RE: Second Request - Limit Filed InputRavi Raman20 Mar
    • RE: Second Request - Limit Filed InputBill Marrs20 Mar
      • RE: Second Request - Limit Filed InputRavi Raman20 Mar
        • RE: Second Request - Limit Filed InputBill Marrs20 Mar
  • RE: Second Request - Limit Filed InputCal Evans20 Mar
RE: Second Request - Limit Filed InputShankar Unni21 Mar
  • RE: Second Request - Limit Filed InputSinisa Milivojevic22 Mar