I'm fairly new to OO Perl, and I have a question about
incorporating a method call into an existing transaction
eval.

Here's the situation - I've just created new class(module)
ABC.pm, and it has an "insert" method in it, and that
insert method has an eval transaction in it including
turning AutoCommit and RaiseError off, doing the prepare
and execute of the insert, and finally a commit - and it
does error processing if the eval had a problem, and if
it did have a problem, it does a rollback(it's Oracle)
and returns 'ERROR' to the caller - otherwise it returns
'OK'.

I'd like to incorporate invoking that insert method into
another existing transaction, which basically looks like
this:


  $dbh->{RaiseError} = 1;
  $dbh->{AutoCommit} = 0;
  eval {

     ### Existing code here(SQL, prepare, execute, etc) to
     ### insert rows into 2 different tables

     ### I want to add these next 2 lines in to this eval
     $rc = $my_obj->insert; ### my_obj is an object of ABC
     die "my_obj insert error" if $rc eq 'ERROR';

     $dbh->commit;
  };
  if ($@) {
     ### do rollback and handle transaction error here
  }

-------------------------------------------------------------

But it seems like it won't work - an eval in an eval - can
someone just confirm for me that this won't work?

TIA.

-- 
Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com

Reply via email to