Hello fellow monks! Been a while but I am back in the monk game with a new question for my favorite monastery. I am coding a script to take HUGE ammounts of data and place it in a postgres database, more specifically a 4 column table within it, in a simple structure. I have been toying with the "copy" functionality from SQL and I have found it to work incredibly well from the command line, and extremely fast. However, when attempting to do this from a perl script via DBI, i get some strange errors. Please consider the following
my $copySQL = "copy snapshot_$formName (name, value, collect_date, omp_id) from ?" my $sth = $dbh->prepare($copySQL); $sth->execute($db_input);
FYI, $db_input is a variable created in the foreach loop that creates the input file, it is explicit in its file location, and again this exact SQL format works perfectly when logged into psql. The errors I get look like this:
DBD::Pg::st execute failed: ERROR: missing data for column "collect_d +ate" at ./getSnapshot.pl line 180, <FORM_OUT> line 103. Couldn't execute copy snapshot_cco (name, value, collect_date, omp_id) + FROM '/tmp/snapshot_mil-newberlin1_cco.input' statement: 7 at ./getS +napshot.pl line 180, <FORM_OUT> line 103.
The file I am inputting looks like this:
csno,100,20040908,32 alarm1.equip[1] y 20040908 32 alarm1.equip[10] y 20040908 32 alarm1.equip[11] y 20040908 32
The truly strange thing about this is that it fails on line 102 or 103 everytime, the first 100 or so make it through just fine. So whattyah say brethren, can yah help me out?


Tradez
"Never underestimate the predictability of stupidity"
- Bullet Tooth Tony, Snatch (2001)

In reply to DBD::Pg copy issues by tradez

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.