Ver Mensaje Individual
  #2  
Antiguo 24-07-2008
Avatar de RolphyReyes
RolphyReyes RolphyReyes is offline
Miembro
 
Registrado: ago 2004
Ubicación: Santo Domingo
Posts: 285
Reputación: 20
RolphyReyes Va por buen camino
Smile

Saludos.

Como consejo revisa bien el manejo de las transacciones por lo regular no es buena practica el realizar bloqueos explícitos.

Te pongo la referencia del Release Notes de FB 1.5:
Cita:
(1.5) Explicit locking
Nickolay Samofatov
The addition of the optional WITH LOCK clause provides a limited explicit pessimistic locking capability
for cautious use in conditions where the affected row set is
1. extremely small (ideally, a singleton) AND
2. precisely controlled by the application code.
Caution
This is for experts only!
The need for a pessimistic lock in Firebird is very rare indeed and should be well understood before
use of this extension is considered.
It is essential to understand the effects of transaction isolation and other transaction attributes before
attempting to implement explicit locking in your application.
Syntax Pattern
SELECT ... FROM <sometable>
[WHERE ...]
[FOR UPDATE [OF ...]]
[WITH LOCK]
...;
If the WITH LOCK clause succeeds, it will secure a lock on the selected rows and prevent any other
transaction from obtaining write access to any of those rows, or their dependants, until your transaction
ends.
If the FOR UPDATE clause is included, the lock will be applied to each row, one by one, as it is
fetched into the server-side row cache. It becomes possible, then, that a lock which appeared to succeed when requested will nevertheless fail subsequently, when an attempt is made to fetch a row
which becomes locked by another transaction.
The SELECT... WITH LOCK construct is available in DSQL and PSQL.
Important
The SELECT... WITH LOCK construct can succeed only in a top-level, single-table SELECT statement.
It is not available
• in a subquery specification
• for joined sets
• with the DISTINCT operator, a GROUP BY clause or any other aggregating operation
• with a view
• with the output of a selectable stored procedure
• with an external table

Examples using Explicit Locking
i) (simple)
Código SQL [-]
SELECT * FROM DOCUMENT WHERE ID=? WITH LOCK

ii) (multiple rows, one-by-one processing with DSQL cursor)
Código SQL [-]
SELECT * FROM DOCUMENT WHERE PARENT_ID=?
FOR UPDATE WITH LOCK
Hasta luego.
__________________
Gracias,
Rolphy Reyes
Responder Con Cita