i'm often facing the same problem. my solution - well, for mysql only - lies in performing a "show table status" query and then selecting the auto_increment value minus 1.
language is a virus from outer space.
Comment on Re: Sequences, last_insert_id, SQLite, and Oracle