1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| delimiter$$
DROP PROCEDURE IF EXISTS `p_completeBuilding`;
CREATE PROCEDURE `p_completeBuilding`(
IN `in_isMovable` TINYINT UNSIGNED,
IN `in_objectID` INT UNSIGNED,
IN `in_conteinerID` INT UNSIGNED,
IN `in_Durability` SMALLINT UNSIGNED
)
BEGIN
declare is_container, type_id, new_container_id INT UNSIGNED default NULL;
declare container_name varchar(45) default NULL;
if(in_isMovable = 1) then
SELECT ObjectTypeID FROM movable_objects WHERE ID = in_objectID LIMIT 1 INTO type_id FOR UPDATE;
else
SELECT ObjectTypeID FROM unmovable_objects WHERE ID = in_objectID LIMIT 1 INTO type_id FOR UPDATE;
end if;
SELECT IsContainer, Name FROM objects_types WHERE ID = type_id LIMIT 1 INTO is_container, container_name;
if(is_container > 0) then
SET new_container_id = f_createRootContainer(container_name);
end if;
if(in_isMovable = 1) then
UPDATE movable_objects SET
IsComplete =1,
RootContainerID = new_container_id,
Durability =in_Durability,
CreatedDurability =in_Durability
WHERE ID = in_objectID;
else
UPDATE unmovable_objects SET
IsComplete =1,
RootContainerID = new_container_id,
Durability =in_Durability,
CreatedDurability =in_Durability
WHERE ID = in_objectID;
end if;
CALL f_deleteContainer(in_conteinerID);
END$$
DELIMITER; |
Partager