And another thing - if you are using a reasonably recent version of Sybase you should probably consider recoding this using Sybase::CTlib (and/or Sybase::BLK). The old DBlib API does not support bcp-ing data into DOL (row level locking) tables, and does not support wide varchar columns, etc.
Using Sybase::CTlib your routine becomes something like this:
sub bcpInsert
{
my ($table, $_rows) = @_;
my $bcp = new Sybase::CTlib $user, $pass, $server,
undef, {CON_PROPS => {CS_BULK_LOGIN => CS_TRUE}};
$bcp -> blk_init($table, $#{@$_rows[0]}, 0, 0);
# perform the db upload
my $count;
my $rows;
my $totrows = 0;
foreach my $row (@$_rows) {
$bcp -> blk_rowxfer($row);
$bcp -> blk_done(CS_BLK_BATCH, $rows)
unless (++$count % 100); # commit every 100 rows
if($rows != 100) {
warn "blk_done(BATCH) only committed $rows rows";
}
$tot_rows += $rows;
}
$bcp -> blk_done(CS_BLK_ALL, $rows); # commit the last batch of da
+ta
$tot_rows += $rows;
$bcp -> blk_drop;
warn "Debugging: bcpInsert loaded $tot_rows rows\n";
warn "Debugging: bcpInsert returning ..\n";
}
Michael
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.