Try this within mysql or fire up DBI and do the following:
alter table TABLE_IN_QUESTION modify FIELD_NAME int unsigned not null +auto_increment;
When inserting, just don't list that field. i.e.
# our table CREATE TABLE example ( id int unsigned not null primary key auto_increment, num int, str varchar(50) ); # our insert statement insert into example (num,str) values(5,"hello"); # test and see what we get select * from example; +----+------+-------+ | id | num | str | +----+------+-------+ | 1 | 5 | hello | +----+------+-------+ 1 row in set (0.00 sec)
If you need to get the value the primary key field was set to during insertion, you can call select last_insert_id() as a lone statement and it will return the value.
Hope this helps.
antirice
The first rule of Perl club is - use Perl
The ith rule of Perl club is - follow rule i - 1 for i > 1
In reply to Re: Perl/DBI autoincrement
by antirice
in thread Perl/DBI autoincrement
by Digitus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |