
USE parts;

DROP PROCEDURE IF EXISTS parts.p_dog_clear_calc_command;
DROP PROCEDURE IF EXISTS parts.p_command_clear_calc_command;

DELIMITER //
CREATE PROCEDURE parts.p_dog_clear_calc_command (
	  IN a_guid BINARY(36)
    , IN a_debug BIT
)
BEGIN
	DECLARE v_time_start TIMESTAMP(6);
    SET v_time_start := CURRENT_TIMESTAMP(6);
    
    CALL parts.p_core_validate_guid ( a_guid );
    
	START TRANSACTION;
		
		DELETE COMMAND_T
        FROM parts.DOG_Command_Temp COMMAND_T
		WHERE COMMAND_T.GUID = a_guid
		;
		
		DELETE COMMAND_CATEGORY_T
        FROM parts.DOG_Command_Category_Temp COMMAND_CATEGORY_T
		WHERE COMMAND_CATEGORY_T.GUID = a_guid
		;
	
	COMMIT;
    
    IF a_debug = 1 THEN
		CALL parts.p_debug_timing_reporting( v_time_start );
    END IF;
END //
DELIMITER ;

/*

CALL parts.p_dog_clear_calc_command (
	'crips                               ' -- a_guid
    , 1 -- debug
);

SELECT *
FROM parts.DOG_Calc_User_Temp
WHERE GUID = 'chips                               '
;

*/
