How to disable "opt for upgrade" in Oracle using Perl DBI

Is there an easy way to timeout the SQL statement so that it works, rather than expecting (for example, delivering an empty result set or an error message or something else) so that I can allow ressource to refuse reservation and give another chance? I am looking for some version of DBI that I still forgot; sending SIGALRM to myself to commit suicide is probably not what I mean (although I might have to resort to it if I had to).

The compiled code is pseudo-measured and abbreviated to the extreme, but I hope you catch the drift.

my $sql = "SELECT one, two, three FROM sometable WHERE this = ? AND that = ?";
my $sth = $self->make_handle( $sql );
eval {
    foreach my $this ( sort keys %needed_ressources ) {
        # vvv This is where the idle time is spent vvv
        $sth->execute( $this, $that ) or die( "DB connection gone?!" );
        # ^^^ This is where the idle time is spent ^^^
        my ( $one, $two, $three ) = $sth->fetchrow_array();
        unless( $one ) { # undefined record set == not found
            $self->{DB_HANDLE}->rollback();
            die( "$this not defined for $that!" );
        }
    }
    # If we haven't died so far, we can move on
    foreach... #similar loop here doing the actual update statement
    $self->{DB_HANDLE}->commit();
};
return( 1 ) unless $@;
return( undef );

Here are the details for those interested:

, , ressource, . / . , , ( ).

, "SELECT... FOR UPDATE", Oracle , . , , , , .

. " " , Oracle , , , , , . , , . un , , , .

RTFM, M, TF R; -))

,
Olfan

+3
2

, NOWAIT FOR UPDATE. , ( "ORA-00054: NOWAIT" ) , . SQL. 11g, .

- : "FOR UPDATE WAIT 3" 3 , , .

+7

, SIGALRM . .

+2

Source: https://habr.com/ru/post/1710012/


All Articles