Comparaison des versions

Légende

  • Ces lignes ont été ajoutées. Ce mot a été ajouté.
  • Ces lignes ont été supprimées. Ce mot a été supprimé.
  • La mise en forme a été modifiée.

...

2 - Enregistrements verrouillés

One or several lines in a table can be locked. This is caused by a process which modified records in a table without committing the changes. The consequence is that no other process can modify the lines before the first commit or rollback was executed. Even a locked record can not be modified, it can be read by another database user.

With the reserved world *LOCKED, it is possible in Adelia to check if a record is locked. It needs to be used after a database modification statement (UPD_SQL or DELETE).

Une ou plusieurs lignes d'une table peuvent être verrouillées. Ceci peut être dû à un processus qui a modifié des éléments sans pour autant avoir validé (commit) les modifications. En conséquence, aucun autre processus ne pourra modifier les lignes avant qu'une instruction VALIDER_MAJ (ou ANNULER_MAJ) n'ait été exécutée.
Si un enregistrement verrouillé, alors il ne pourra pas être modifié. Par contre il pourra être lu par un autre utilisateur.

Le mot reservé *BLOQUE permet de vérifier si un enregistrement est verrouillé. On le consulte après un accès modifiant la base de données (MAJ_SQL ou SUPPRIMER_SQL etc..).

  • *BLOQUE = '1' : l'enregistrement est verrouillé 
  • *BLOQUE = '0' : l'enregistrement n'est pas verrouillé (on peut également utiliser la constante _RECORD_LOCKED à la place de la valeur
  • *LOCKED = '1' : record is locked 
  • *LOCKED = '0' : record is not locked (we can use the constant _RECORD_LOCKED instead of the value '1')


Remarque
titleAttention

By default Oracle waits an infinite amount of time after an update (or delete) operation if the record is locked.
It would answer only after the record has been released.
To change this behavior, we must use the 'VaToolBxSetTimeOut' method of the VaToolBx library (see example belowPar défaut Oracle attend un temps "infini" après une opération de mise à jour/suppression si un enregistrement est verrouillé.
La main sera rendue au programme seulement lorsque l'enregistrement aura été libéré.
Pour changer ce comportement, on utilisera la méthode 'VaToolBxSetTimeOut' de la VaToolBx library (cf exemple ci-dessous)


Bloc de code
/* ___ Code _____________________________________________________________________________

/* ___ Force Oracle to answer after a certain amount of time, even if the record is locked ______________________________
/* ___ Here we will have an answer after 5 seconds maximum. _____________________________________________________________
/* ___ The 'P' parameter means all the queries submitted during the session will have this timeout delay ________________
/* ___ A 'T' parameter would mean that only the next query submitted during the session would have this timeout delay ___

call_dll 'VATOOLBX.DLL' 'VaToolBxSetTimeOut' 5 'P' returnCodeBool

/* ___ Try to do an update to a database record ___

upd_sql employee age = age + 1 - 
				   *cond( name='milkwater')										 
if *locked = _RECORD_LOCKED
	/* the record(s) is(are) locked 
else
	/* the record(s) is(are) not locked and has been updated
end

...