Subject Re: [firebird-support] get_lock / release_lock
Author Kjell Rilbe
Doru Constantin wrote:
> I have an old app: vfp + odbc + mysql.
> I try to replace mysql with minimal change in code.
> In this app when a user is add/modify/delete a document the get_lock()
> function is called and if the lock is get then the user can continue
> otherwise don't.
> I read about RDB$SET_CONTEXT / RDB$GET_CONTEXT, but "... variables may be
> read and written to and by whom are determined by namespace which they
> belong to.".
> I need RDB$SET_CONTEXT / RDB$GET_CONTEXT but in a global context.

After reading Helen's reply, I think you need to clarify what a
"document" is in your app. Is it a data item stored in the DB? A BLOB
field? An external file, whose name is stored in the DB?

Do you need pessimistic locking, so that the user can't START editing
without obtaining a lock?

Is this a kind of check-out-and-lock/check-in-and-release feature?

If it's a (BLOB or other) field and optimistic locking is OK, then your
simply need to try the insert or update with the new/modified document,
and if it fails, then you have to catch the exception and handle the
conflict in your app.

If it's more like check-in/check-out with pessimistic locking, then you
need something like what I suggested (or possibly the RDB$GET_CONTEXT
etc which I'm not familiar with).

Kjell Rilbe
E-post: kjell@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64