I’m developing a hospital management system, as you know is a huge system, to make things clear, Reception will open a new ticket for the patient Ticket no will be a customized form month year no (112011000101) which mean ticket no 101 on the month Nov on 2011.
When saving the ticket, my application will read the last saved ticket no & increase the no with one, (Select Tick_No from tickets where Tick_No Like ‘112011’% order by Tick_No DESC limit 1), this will return the last saved ticket which is (112011000101) increment by one ==> new ticket will be (112011000102).
So if there are two employees saving new tickets in the same is there is a chance to get duplicate ticket no??
I’m using transactions with mysql database which will make a row-level locking but still table available for any queries.
so i need a clear answer please if it is possible.
note in my code, when saving if something go wrong a rollback will be issued and auto retry saving function will be issued (in each saving order the application will perform check for the last number).
You should make a table-level locking in this case, so you could use the
MyISAMtable engine. This should help http://dev.mysql.com/doc/refman/5.0/en/lock-tables.html