Re: Enum default values

2004-01-05 Thread Martijn Tonies
Hi, > > This usually comes up when people expect an exception to be thrown when > they assign NULL to a NOT NULL column, but this is the same idea. From > the manual : Indeed. One of those weird MySQL things. Is this different on InnoDB? > >

Re: Enum default values

2004-01-05 Thread Michael Stassen
Martijn Tonies wrote: Hi, [snip] 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. This string can be distinguished from a 'normal' empty string by the fact that this string h

Re: Enum default values

2004-01-05 Thread Martijn Tonies
Hi, > [snip] > > 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. This string can be distinguished > from > > a 'normal' empty string by the fact that this string has th

RE: Enum default values

2004-01-05 Thread Jay Blanchard
[snip] > 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. This string can be distinguished from > a 'normal' empty string by the fact that this string has the numerical > val

Re: Enum default values

2004-01-05 Thread Martijn Tonies
> [snip] > Yes, the DEFAULT doesn't apply. However, shouldn't MySQL > raise an exception because '' isn't a valid value for this ENUM > specification? > [/snip] > > >From http://www.mysql.com/doc/en/ENUM.html > > The value may also be the empty string ("") or NULL under certain > circumstances:

RE: Enum default values

2004-01-05 Thread Jay Blanchard
[snip] Yes, the DEFAULT doesn't apply. However, shouldn't MySQL raise an exception because '' isn't a valid value for this ENUM specification? [/snip] >From http://www.mysql.com/doc/en/ENUM.html The value may also be the empty string ("") or NULL under certain circumstances: If you insert an in

Re: Enum default values

2004-01-05 Thread Martijn Tonies
Hi, > [snip] > insert into property values ('','Book-keeper\'s Cottage','Thu'); > insert into property values ('','Inglenook Barn','Fri'); > insert into property values ('','Maggie\'s House','Fri'); > insert into property values ('','Riverside View',''); > insert into property values ('','The Mans

Re: Enum default values

2004-01-05 Thread Richard Dyce
Jay! Thanks for help with a 'proper' insert. ;-) Yes, the full statement works fine. (I assume this is something like the not setting default values from importing DATA files?) All a bit of a shame, as I'm executing the insert from a PHP script, and was trying to make the routine as generic as

RE: Enum default values

2004-01-05 Thread Jay Blanchard
[snip] insert into property values ('','Book-keeper\'s Cottage','Thu'); insert into property values ('','Inglenook Barn','Fri'); insert into property values ('','Maggie\'s House','Fri'); insert into property values ('','Riverside View',''); insert into property values ('','The Manse',''); insert in

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 t

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

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 enu

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 2002.0

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 ass

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" > > I

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." > Th

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
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 -

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 p

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
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 >