On Mon, Mar 05, 2001 at 10:26:58PM -0600, Mike<mickalo>Blezien wrote:
> Hello All,
>
> I've created a table(using MySQL 3.23.33), using default values:
>
> DROP TABLE IF EXISTS referral;
> CREATE TABLE referral (
> refer_id int(10) UNSIGNED DEFAULT '100' NOT NULL,
> refer_fname varchar(20) DEFAULT '' NOT NULL,
> refer_lname varchar(20) DEFAULT '' NOT NULL,
> refer_email varchar(40) DEFAULT '' NOT NULL,
> UNIQUE INDEX idx_refid (refer_id)
> ) TYPE=MYISAM;
>
> It creates the table, no problems. But for some reason, if the refer_id is left
> blank during an INSERT, it defaults to "0" and not 100 ?? is this because of the
> UNIQUE INDEX on this column?? If your wonder, the refer_id is assigned a random
> 5 digit number within the Perl program. I was just testing to see if it would
> assign the default value if no value was assigned during an insert.
>
Exactly what does your INSERT look like?
A default value for refer_id should be inserted when you do:
INSERT INTO referral(refer_fname, refer_lname, refer_email)
VALUES ('xxx.yyy', 'xxx.yyy', '[EMAIL PROTECTED]');
or:
INSERT INTO referral
VALUES (NULL, 'xxx.yyy', 'xxx.yyy', '[EMAIL PROTECTED]');
But an INSERT like this:
INSERT INTO referral
VALUES ('', 'xxx.yyy', 'xxx.yyy', '[EMAIL PROTECTED]');
will probably use 0 for refer_id or give an error message. You do
supply a value in this case, so no default wil be used.
Regards,
Fred.
--
Fred van Engen XO Communications B.V.
email: [EMAIL PROTECTED] Televisieweg 2
tel: +31 36 5462400 1322 AC Almere
fax: +31 36 5462424 The Netherlands
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php