Since you have the good fortune of knowing that the old DBM file is always returning records in the desired order, all you have to do is make up a "pseudo" posttime value for each record so that these values preserve the ordering in mysql.

E.g. the first record would have a posttime that is (roughly) when the service began, the last record from the DBM file would be set to the time when the DBM file was phased out, and all intermediate records would have values that differ by a regular increment ((end_time - begin_time)/(record_count+2) would probably suffice).

I gather from one of your other replies that the DBM file does not include posttime values, but that as new posts are added to the mysql table, these values will be properly stored. So just be sure that the "pseudo" posstime values that you make up for the old data do not overlap with the "true" values being generated by the ongoing collection.

BTW, shouldn't posttime values include a date as well as hours:minutes:sec?

UPDATE: A couple other points I forgot to notice/mention: First, it looks like you actually do have key values in the DBM file that, when sorted, produce the desired ordering. What kind of string makes up a key value? Can that string be reasonably converted into some sort of time expreassion for use as the "posttime" value?

Second, if you have a lot of records to insert, you'll want to move the "prepare()" statement outside the foreach loop -- you are already using placeholders, so you might as well use them as they were intended to be used: prepare once, execute many times with different values passed in each iteration of the execute call.


In reply to Re: database not in correct order by graff
in thread database not in correct order by Anonymous Monk

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.