Subject Re: [firebird-support] How do I "lock tables" in FireBird SQL?
Author Martijn Tonies
Hi,

> I've just joined and I'd like to ask for your help.
>
> I'm migrating from MySQL to Firebird (Firebird seems to be sooo much
better!) and I've run into a database design issue.
>
> In the system I'm designing, multiple users access documents, but one
document can only be edited by one person at a time.
>
> Thus, I thought about creating a separate "resource reservation" table,
where users can reserve resources for themselves - till they need it.
>
> A typical reservation would consist of a SELECT then an INSERT operation.
If the SELECT operation says that there is no other reservation on that
SPECIFIC record, the user can use INSERT to reserve it.
>
> The problem: between one user's SELECT and INSERT statements, another user
could do an INSERT - the result would be 2 reservations on the same
resource, which is a catastrophe!

Make sure the table has a unique constraint on "document to edit" and you
cannot insert 2 of the same in it. So, if the insert fails, someone else is
editting the document.

Martijn Tonies
Database Workbench - development tool for MySQL, and more!
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com

> In MySQL, you could issue a LOCK TABLE command, do the select/insert then
call UNLOCK TABLES.
>
> How do I go about solving this problem in Firebird? What's the best
solution for this?
>
> Thank you so much for the help!
>
> -Zd
>
> [Non-text portions of this message have been removed]
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://www.firebirdsql.org and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Yahoo! Groups Links
>
>
>
>
>