다음 mysql query를 db2용으로 어떻게 바꿔야 하나요? @max 와 같이 변수를 쓸 수 없는 것 같던데요
start transaction;
select @max := max(id) from reservation;
select @min := min(id) from reservation;
select @diff := @max - @min;
select @id1 := FLOOR(@min + RAND() * @diff);
select @id2 := @id1 + FLOOR(RAND() * (@max - @id1));
select @checkin1 := check_in, @duration1 := duration from reservation where id = @id1 for update;
select @checkin2 := check_in, @duration2 := duration from reservation where id = @id2 for update;
update reservation set check_in = @checkin1, duration=@duration1 where id = @id2;
update reservation set check_in = @checkin2, duration=@duration2 where id = @id1;
commit;
|