You have a race condition in there...what if someone inserts into the ECAST_LOT table after you've selected the latest id, but before you've inserted into it? Look at DBIx-Sequence for a correct way of doing this sort of thing, or use built in sequences, auto-increment or unique-id columns, or whatever your database supports.

And SELECT TOP 1 IDX FROM ECAST_LOT ORDER BY IDX DESC seems like an inefficient way of doing SELECT max(IDX) FROM ECAST_LOT (how big is the table on each server? is there an index on the column or is it a primary key?). Also, I hope none of the fields being inserted has single quotes in it.

.

In reply to Re: ActivePerl sql connection~PLEASE HELP!! by runrig
in thread ActivePerl sql connection~PLEASE HELP!! by MelaOS

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.