You can wrap it in an exec block and then check $@ after completion, like this:

eval {
        $sth_ins_user->execute(
                $user_id,
                $username,
                $password
                );
        };

if ($@) {
   # custom error-handling
   $dbh->rollback();
   $dbh->disconnect();
        
   if ($@ =~ /^DBD::ODBC::st execute failed: \[Oracle\]\[ODBC\]\[Ora\]ORA-
00001: unique/) {
        print 'That username has already been selected';
        DieOnError($msg);
        }
   else {
         print "Other error";
         }
   exit();
   }


The specific syntax of what you need to check for in $@ is DB-specific, so the 
code here will only work for Oracle.

Paul

Quoting [EMAIL PROTECTED]:

> I am just begginning to utilize perl w/apache. Since the amount of
> documentation for perl is so overwhelming, I hope this list can help me
> out.
> 
> Question: How can I determine that a failure on insert is caused by
> duplicate value/primary keys? I would like to handle this specific failure
> separately from other failure.
> 
> thanks,
> -rkl
> 


Reply via email to