Mark, you need to read the perldocs for the DBI module - you can do that
by doing

   perldoc DBI

at a command prompt.  Search (on *nix by using the forward "/" slash)
in the perldocs for "Transaction" and "eval".  You can also look here:

   http://www.perldoc.com/perl5.6.1/lib/DBI.html#Transactions

Here's a snippet showing how to use eval for error trapping:

  $dbh->{AutoCommit} = 0;  # enable transactions, if possible
  $dbh->{RaiseError} = 1;
  eval {
      foo(...)        # do lots of work here
      bar(...)        # including inserts
      baz(...)        # and updates
      $dbh->commit;   # commit the changes if we get this far
  };
  if ($@) {
      warn "Transaction aborted because $@";
      $dbh->rollback; # undo the incomplete changes
      # add other application on-error-clean-up code here
  }

The "eval" causes die's inside that block to populate "$@" with the
text of the die message, and then causes execution to continue with the
next statement after that eval block.  I'm not sure what your specific
problem is, but this info. might give you some ideas.  Post back if
you're still having problems.

Hardy Merrill

>>> Mark Martin <[EMAIL PROTECTED]> 04/02/04 09:23AM >>>
Hi,
Database is Oracle.
The user does have update permissions
Connect Statement - $dbh = DBI->connect( "dbi:Oracle:database",
"user",
"pwd" ) or die "Can't connect to Oracle database: $DBI::errstr\n";
Error checking - yes the real programs have error checking on but
nothing is
coming back.
You asked about -RaiseError,PrintError, and AutoCommit - afraid I'm
not
familiar with these.
Thanks for responding,
Mark

----- Original Message ----- 
From: "Hardy Merrill" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, April 02, 2004 3:06 PM
Subject: Re: My DBI script wont UPDATE a Table!


> Paste in your database connect statement.  Are you setting
RaiseError,
> PrintError, and AutoCommit?  Which database are you using?  Are you
> doing any error checking of DBI statements?  And as was just pointed
out
> by someone else, does the user you are connecting with have update
> permissions in your production database?
>
> >>> Mark Martin <[EMAIL PROTECTED]> 04/02/04 08:52AM >>>
> Hi,
> I designed my application on a test database and it worked fine
without
> commiting the database handle. But now when I've moved it to the
> production database my updates wont commit - even when I do issue a
> commit on the DBH?!?!
>
> while(certain condition) {
>                                     $sql = qq{UPDATE table SET
> field=value} ;
>                                     $sth = $dbh->prepare($sql) ;
>                                     $sth->execute;
>
>                                     $dbh->commit();
>
>                                   }
> $sth->finish;
> $dbh->disconnect;
>
> I've tried the commit outside the while statement with no luck. Any
> ideas?
> Mark

Reply via email to