You could solve this on the database side using transaction boundaries and an exclusive lock via UPDATE statements.

Setting up a lock table:

create table "LockTable" ( LockID integer primary key, LockTable varch +ar(255) NOT NULL, LockTime datetime NULL); insert into "LockTable" values (0, '', NULL); insert into "LockTable" values (1, 'MyTable', NULL);

Then using it to force INSERT statements to queue up (all INSERT statements have to play by the rules for this to work; not as effective in an ad hoc environment but great if you control the process):

begin transaction; update "LockTable" set LockTime=CURRENT_TIMESTAMP where LockTable = 'M +yTable'; insert into "MyTable" values (a, b, c, etc.); update "LockTable" set LockTime=NULL where LockTable = 'MyTable'; commit transaction;

This trick works in most DBMS systems, although you do have to pay attention to the specific effects if the transaction isolation level is set other than one might expect. It can be a performance soak, though, so use it only where you need it.


In reply to Re: perl script and queue by dbander
in thread perl script and queue by k_manimuthu

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.