unable to add new entries on form with auto_increment option
Posted: Mon Jan 24, 2011 6:56 am
Background:
Package: Windows Installer 111M - downloaded early on Jan 2011from the Download page.
I have created a simple form called "usr_form" which is bounded to a "users" table. This table has a primary key with auto_increment option on it:
use dcr;
drop table if exists users;
CREATE TABLE if not exists users
(userid int not null auto_increment,
primary key (userid),
usr_firstname varchar(30) not null,
usr_lastname varchar(30) not null,
usr_wrk_number varchar(15),
usr_wrk_no_extn varchar(10),
usr_cell_number varchar(15),
usr_email varchar(35),
usr_group varchar(30),
usr_created datetime,
status varchar(30),
mgr_firstname varchar(30) not null,
mgr_lastname varchar(30) not null,
mgr_wrk_number varchar(15),
mgr_wrk_no_extn varchar(10),
mgr_cell_number varchar(15),
mgr_email varchar(35)
) engine=innodb;
I have created two objects on the usr_form just to test it. Object1 is bounded to firstname and object2 to lastname. I was able to add the first entry successfully however when I tried to add the 2nd one I got the following exception:
SQL
INSERT INTO users (userid, usr_firstname, usr_lastname) VALUES ("14d3a093bbddd0", 'c', 'c')
Error
1062: Duplicate entry '14' for key 'PRIMARY'
Just an FYI, my first entry was:
userid=14
firstname=Bob
lastname=Safarian
So it appears nuBuilder is trying to insert an alphanumeric value into the userid with INT data type. To me nuBuilder should have generated an insert statement as the following:
INSERT INTO users (usr_firstname, usr_lastname) VALUES ('c', 'c');
and let MySQL automatically generate and fill in the userid.
Could you please explain this behavior and how to workaround it?
Thanks,
Bob Safarian
Package: Windows Installer 111M - downloaded early on Jan 2011from the Download page.
I have created a simple form called "usr_form" which is bounded to a "users" table. This table has a primary key with auto_increment option on it:
use dcr;
drop table if exists users;
CREATE TABLE if not exists users
(userid int not null auto_increment,
primary key (userid),
usr_firstname varchar(30) not null,
usr_lastname varchar(30) not null,
usr_wrk_number varchar(15),
usr_wrk_no_extn varchar(10),
usr_cell_number varchar(15),
usr_email varchar(35),
usr_group varchar(30),
usr_created datetime,
status varchar(30),
mgr_firstname varchar(30) not null,
mgr_lastname varchar(30) not null,
mgr_wrk_number varchar(15),
mgr_wrk_no_extn varchar(10),
mgr_cell_number varchar(15),
mgr_email varchar(35)
) engine=innodb;
I have created two objects on the usr_form just to test it. Object1 is bounded to firstname and object2 to lastname. I was able to add the first entry successfully however when I tried to add the 2nd one I got the following exception:
SQL
INSERT INTO users (userid, usr_firstname, usr_lastname) VALUES ("14d3a093bbddd0", 'c', 'c')
Error
1062: Duplicate entry '14' for key 'PRIMARY'
Just an FYI, my first entry was:
userid=14
firstname=Bob
lastname=Safarian
So it appears nuBuilder is trying to insert an alphanumeric value into the userid with INT data type. To me nuBuilder should have generated an insert statement as the following:
INSERT INTO users (usr_firstname, usr_lastname) VALUES ('c', 'c');
and let MySQL automatically generate and fill in the userid.
Could you please explain this behavior and how to workaround it?
Thanks,
Bob Safarian