Dear Monks, I'm having a problem with Perl DBI returning a random field order when interacting with a MS Access 2000 database.

Query follows:

$query = "select id_code, title, author, html_hyperlink, entry_date, i +sbn, ddc, dewey_class, lcc,book_details, language, physical_descripti +on, discard_ind from books_main where $sort_by = '$id_code' order by +$sort_by";

Where variable $sort_by is one of the other fields listed above (isbn, id_code, etc).

My problem is with data display. When the query returns records from MS Access, the fields are not in the order selected above, and in fact are in different orders depending on the value of the where clause. IE if ISBN is selected, the fields are returned in different order than if AUTHOR is selected.

I am viewing the data via something like following:

!$db->Sql($query) || Handle_Errors("$current_time couldn't do query: $ +query because " . $db->Error() ,1, $db->Error() . " $? $!",1); <p> while($db->FetchRow()) { @data = $db->DataHash(); $cycle_1 = $data[0];## physical desc field_name $cycle_2 = $data[1]; physical desc data $cycle_3 = $data[2];## language field name ###etc.....
Is there anything I can add to the query, or a different manner of output where the fields will appear in a consistent manner? This makes any field-specific manipulation post-query very difficult. Thanks.

Perl Version:

This is perl, v5.8.8 built for MSWin32-x86-multi-thread (with 33 registered patches, see perl -V for more detail)


In reply to DBI help - MS Access random field order by The_Overdog

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.