Hi,

with the following Perl-code:

    $dbh = DBI -> connect ("dbi:Sybase:server=$DBSERV", $DBUSER, $DBPASS,
                           { RaiseError   => 1,
                             AutoCommit   => 1,
                             ChopBlanks   => 1,
                             syb_show_sql => 1, });
...
    $sth = $dbh -> prepare (sprintf 'delete_release %s',
                                    $dbh -> quote ($release));
    $sth -> execute;

    do {
        while (my $href = $sth -> fetchrow_hashref)
        {
            if (CS_STATUS_RESULT == $sth -> {syb_result_types})
            {
                $res = $href -> {'COL(1)'}; # result of stored proc
                last;
            }
        }
    }
    while ($sth -> {syb_more_results});

    print abstract ($res ? q{Modifying the database has failed.} : 
        qqr{The <B>$release</B> has been deleted from the database.});

I'm trying to catch the return code of this stored procedure:

    create procedure delete_release @release varchar (32)
    as
        delete SWRFILES where RELEASE = @release

But it doesn't work when I delete a record REFERENCEd from another table:

    DBD::Sybase::st execute failed: Server message number=547 severity=16 
    state=1 line=3 procedure=delete_release text=Dependent foreign key 
    constraint violation in a referential integrity constraint. dbname = 
    'acapackdel', table name = 'SWRFILES', constraint name = 
    'LOADFILES_RELEAS_1584008674'. Statement=delete_release 'R9 CN1' Server 
    message number=3621 severity=10 state=0 line=3 procedure=delete_release 
    text=Command has been aborted.  Statement=delete_release 'R9 CN1' 

- the execute fails, because I've set RaiseError => 1. But I wonder
if there is a way to catch this error in the stored procedure, so that
the script doesn't die? Just the $res should be non-zero. Thank you

Regards
Alex

Reply via email to