Check out this tutorial for examples: http://www.sa-mart.com/ftp/pub/perl/Docs/Win32/ODBC/odbc-Tutorial.htm and http://www.roth.net/perl/odbc/

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.