Results 1 to 2 of 2

Thread: "select into outfile": wrong field length

  1. #1
    Join Date
    Oct 2005
    Posts
    1

    "select into outfile": wrong field length

    Hi,

    I have to export data from a database in a special form (the customer wants it this way): every record in one line, and all fields in a large string. Thus, only by convendion it is defined the first seven characters being the central number, the next fivr characters the number of this spare part type, the following 30 the description, and so on...
    Just at the end of every record has to be CF-LF.

    all works well so far by with this code (in PHP) -
    except one thing - see details below the code snippet):

    $q1 = "SELECT dirc_matdata.* FROM dirc_vorgang, dirc_matdata ";
    $q2 = "WHERE dirc_vorgang.rep_out> '".$anf_dat."'";
    $q3 = "AND dirc_vorgang.rep_out < '".$end_dat."'";
    $q4 = "AND dirc_matdaten.auftrags_nr = dirc_vorgang.auftrags_nr";
    $q5 = "INTO outfile '".$drive.":/matdata.dat'";
    $q6 = "FIELDS TERMINATED BY '' LINES TERMINATED BY '\r\n';";
    $query = $q1.' '.$q2.' '.$q3.' '.$q4.' '.$q5.' '.$q6;

    The INT (integer) fields appear in the (plain text) output file with wrong field lengths. Although I had set the first field (i.e. the number of this type ofparts) to a length of 5, this field appears in the outfile being 10 characters long -- the maximum length of a normal INT type field (and twice as long as it should be).

    Or (when set to filed type "MEDIUMINT"), it appears in the length of 8 characters only. But I need this data exactly 5 characters long in this application.

    BIG QUESTION: How can I make mySQL (Ver. 4.1) write this fields into the outfile with their correct length as defined in the database structure?

    Is this flaw already known in the community?
    Is there any sort of "workaround"?

    Thank you for every hint!

    -ah-

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    You should post this in MySql forum.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •