1

Topic: Correct method of isolation of the data

Kind time of days!
Situation:
Tables:
room
daily_room_status
room_category
room_status
HTML page with the form of booking of a room the user.
Protses of booking - transaction in 2 stages:

SELECT r.id
FROM room AS r
INNER JOIN daily_room_status AS drs
ON r.id = drs.room_id
INNER JOIN room_category AS rc
ON r.category_id = rc.id
WHERE rc.category =?
AND r.size =?
AND drs.status_id IN (SELECT id FROM room_status WHERE STATUS IN (' CUSTOMER '))
AND (drs.date BETWEEN? AND?)
GROUP BY r.id
HAVING COUNT (r.id) = (TO_DAYS (?) - TO_DAYS (?))

2. If ResultSet request from  1 nonblank there is a room armor protection (changes its status in the table daily_room_status):

UPDATE daily_room_status
SET status_id = (SELECT id FROM room_status WHERE STATUS =?)
WHERE room_id =? AND (DATE BETWEEN? AND?)

The Question:
How correctly to isolate transaction that no other request could change the data between 1 and 2 stages?
Thanks!

2

Re: Correct method of isolation of the data

SELECT. FOR UPDATE