in reply to MCE and DBI - [SOLVED]
Hi Panos,
Thank you for providing a code sample. I added user_begin and user_end options. In MCE, workers call user_begin and user_end one time (before and after running). Thus, reconnecting to the DB each time is not necessary.
e.g. { user_begin } { user_func chunk_1 } { user_func chunk_2 } ... { user_func chunk_N } { user_end }
#!/usr/bin/perl -w use strict; use MCE; use DBD::Oracle; use DBI; sub myBegin { my ($mce) = @_; $mce->{db} = DBI->connect( "dbi:Oracle:<SERVER_NAME>", "<USERID>", "<PASSWORD>" ) || die($DBI::errstr . "\n"); return; } sub myEnd { my ($mce) = @_; $mce->{db}->disconnect; return; } sub mySub { my ($mce, $chunk_ref, $chunk_id) = @_; my $db = $mce->{db}; return; } my (@array, $mceObj, $db); $db = DBI->connect( "dbi:Oracle:<SERVER_NAME>", "<USERID>", "<PASSWORD>" ) || die($DBI::errstr . "\n"); ...do some work with the database in order to fill up ...the @array variable... $db->disconnect; $mceObj = MCE->new(max_workers => 4, input_data => \@array, user_begin => \&myBegin, user_func => \&mySub, user_end => \&myEnd); $mceObj->run;
From reading your code, am still not sure the reason for the ora_stmt_type redefined errors stated in the initial post. Connecting one time may solve the issue.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: MCE and DBI
by pmamatsis (Initiate) on May 28, 2015 at 06:07 UTC | |
by marioroy (Prior) on May 29, 2015 at 11:37 UTC |