Re: ENUM Default values on NULL

2002-04-12 Thread Ruben I Safir
sql Hello I need a ENUM to default to a value when it gets a NULL. Can this be done. Right now is I set the column to FIELD ENUM('NO','YES') NOT NULL It fails to insert when a NULL is entered. I want it to default to NO Can I set it to do this? Ruben --

Re: ENUM Default values on NULL

2002-04-12 Thread Steve Katen
ENUM can handle your needs. you should be able to just change your syntax to: FIELD ENUM('NO','YES') NULL under that syntax your default value will be NULL. this is from the documentation directly: If an ENUM is declared NULL, NULL is also a legal value for the column, and the default value

Re: ENUM Default values on NULL

2002-04-12 Thread Ruben I Safir
ENUM can handle your needs. you should be able to just change your syntax to: FIELD ENUM('NO','YES') NULL under that syntax your default value will be NULL. We need it to default to 'NO' not NULL sql Ruben - Before

Re: ENUM Default values on NULL

2002-04-12 Thread Ruben I Safir
sql ENUM can handle your needs. you should be able to just change your syntax to: FIELD ENUM('NO','YES') NULL under that syntax your default value will be NULL. I need it to default to 'NO' not NULL - Before

Re: ENUM Default values on NULL

2002-04-12 Thread Steve Katen
Ruben, If you leave it as NOT NULL it should default to NO. If an ENUM is declared NOT NULL, the default value is the first element of the list of allowed values. SIDE QUESTION: Are you doing something like: select * from table where enum_colum=NO If you are running that type of query it

Re: ENUM Default values on NULL

2002-04-12 Thread Ruben I Safir
When I send a NULL it's rejected as bad data, which sort of makes sense On 2002.04.12 12:33 Steve Katen wrote: Ruben, If you leave it as NOT NULL it should default to NO. If an ENUM is declared NOT NULL, the default value is the first element of the list of allowed values. The

Re: ENUM Default values on NULL

2002-04-12 Thread Gerald Clark
Steve Katen wrote: Ruben, If you leave it as NOT NULL it should default to NO. If an ENUM is declared NOT NULL, the default value is the first element of the list of allowed values. SIDE QUESTION: Are you doing something like: select * from table where enum_colum=NO If you are

Re: ENUM Default values on NULL

2002-04-12 Thread Steve Katen
Ruben, If you insert an invalid value into an ENUM (that is, a string not present in the list of allowed values), the empty string is inserted instead as a special error value. it is inserting the value as the first value in the table which is the error value or the index of 0. i would

Re: ENUM Default values on NULL

2002-04-12 Thread Michael Stassen
Instead of inserting NULL, leave the column out. INSERT mytable (2nd_col_name) VALUES (NULL); If you don't mention the enum column, it gets the default. Michael On Fri, 12 Apr 2002, Ruben I Safir wrote: When I send a NULL it's rejected as bad data, which sort of makes sense On

Re: ENUM Default values on NULL

2002-04-12 Thread Michael Stassen
On Fri, 12 Apr 2002, Steve Katen wrote: Ruben, If you leave it as NOT NULL it should default to NO. If an ENUM is declared NOT NULL, the default value is the first element of the list of allowed values. SIDE QUESTION: Are you doing something like: select * from table where

Re: ENUM Default values on NULL

2002-04-12 Thread Ruben I Safir
Your example is not the same, it sends only one value to a 2 value table. It definetely does not work if you send NULL INSERT VALUES(NULL) Ruben On 2002.04.12 14:10 Michael Stassen wrote: On Fri, 12 Apr 2002, Steve Katen wrote: Ruben, If you leave it as NOT NULL it should default

Re: ENUM Default values on NULL

2002-04-12 Thread Michael Stassen
Ruben, I think youare referring to my earlier message, but no matter. You cannot insert NULL into a column you've defined as NOT NULL, with some special exceptions (auto_increment and timestamp, for example). As I said before, if you want a column to get its default value, you leave it out of