In the SQL you're using, you have your values in one big quoted string (VALUES ("a,b,c...")) instead of as individual values (VALUES ("a", "b", "c")). What you really should do is use placeholders for this.
my $cc = join q{,}, @col;
my $qmarks = join q{,}, map { '?' } @values;
my $sql_2 = qq{INSERT INTO mfa.genome ($cc) VALUES ($qmarks)};
$DBHandle->do( $sql_2, undef, @values );
A few more things stand out here.
- You seem to be populating @col with only the first column of every row you fetch from $hi (whatever that is). Is that really what you meant? I guess you can see from your value of $cc later if it's right.
- You push into @values, but I don't see that it gets cleared anywhere.
- The way you're adding to @values is very not Perlish. You could do the same thing as: push @values, @org[0..9]
- With DBI, you can do() without prepare(). (prepare() is for when you will later execute().)
- The @values you had were going to be passed unquoted to the database. This means that if the values themselves had what looked like SQL code in them, that could be executed. Using placeholders takes care of that, but you can also use the quote() method on a database handle.
- According to the indents, your SQL stuff is happening inside the while loop, but according to the braces, it's outside. Be sure you're looping over what you want to.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.