I don't think Win32::ODBC allows for primary keys, at least not autonumber(java does), you'd probably have to figure out what the greatest key is, and then increment, but if your database is updated while you're doing this, you might run into trouble.\
Anyway i don't like order as a table name, please change it to purchase_order or something ;-)
Anyway check this out too: http://www.sa-mart.com/ftp/pub/perl/Docs/Win32/ODBC/example6.cgi.htm
Here's a snipped:
$db->Sql("SELECT DISTINCT seq FROM purchase_order" );
DBI has this: $new_id = $sth->{insertid};
update: aparently insert id is a mysql specific function, too bad.
An oh yeah, dont forget: http://dbi.symbolstone.org/ and http://www.perldoc.com/cpan/DBD/ODBC.html
update:Here's a better snippe:D
$db->Sql("SELECT MAX(seq) FROM purchase_order");
It'll fetch the lartest unique id, and since it's autonumber, it must be an integer(or long), so you just increment it by 1 and you have your next primary key.
___crazyinsomniac_______________________________________
Disclaimer: Don't blame. It came from inside the void
perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"
In reply to (crazyinsomniac) Re: Win32::ODBC insert question
by crazyinsomniac
in thread Win32::ODBC insert question
by thefid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |