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.


In reply to Re: MCE and DBI by marioroy
in thread MCE and DBI - [SOLVED] by pmamatsis

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.