USE parts;

DROP PROCEDURE IF EXISTS parts.p_dog_test_save_command;


DELIMITER //
CREATE PROCEDURE parts.p_dog_test_save_command ()
BEGIN
	
	DECLARE v_guid BINARY(36);
	DECLARE v_time_start TIMESTAMP(6);
    
    SET v_time_start := CURRENT_TIMESTAMP(6);
	SET v_guid := 'nipple_ripple_chipple_spittle_pickle'; -- 123456789012345678901234567890123456

    SELECT 'Start of Test';

	SELECT *
	FROM parts.DOG_Command
	;
	SELECT *
	FROM parts.DOG_Command_Temp
	;

	START TRANSACTION;
		
		INSERT INTO parts.DOG_Command_Temp (
			  id_command
            , email
            , name_contact
            , name_company
            , message
            , guid
            , active
		)
        /*
		VALUES (
			  -1 -- id_command
			, 'edward.middletonsmith@gmail.com' -- email
			, 'Teddy' -- name_contact
			, 'PARTS Ltd' -- name_company
			, 'Sa dude' -- message
			, v_guid
		)
        */
		VALUES (
			  -1 -- id_command
			, 'edward.middletonsmith@gmail.com' -- email
			, 'Teddy' -- name_contact
			, 'PARTS Ltd' -- name_company
			, 'hegrodorf is good' -- message
			, v_guid
            , 1 -- active
		)
        ;
		
	COMMIT;
    
	SELECT *
	FROM parts.DOG_Command_Temp
	-- WHERE GUID = v_guid
    ;
    
    CALL parts.p_dog_save_command ( 
		  'Test save Command' -- comment
        , v_guid -- guid
        , 3 -- 1 -- id_user
		, 1 -- debug
    );
    
	SELECT *
	FROM parts.DOG_Command
	;
	SELECT *
	FROM parts.DOG_Command_Temp
	;
    
	CALL parts.p_debug_timing_reporting ( v_time_start );
END //
DELIMITER ;


/*
SELECT 'Before Test';
SELECT *
FROM parts.DOG_Command
;
SELECT *
FROM parts.DOG_Command_Temp
;


CALL parts.p_dog_test_save_command ();

SELECT 'After Test';
SELECT *
FROM parts.DOG_Command
;
SELECT *
FROM parts.DOG_Command_Temp
;

DELETE FROM parts.DOG_Command_Temp;

DROP TABLE IF EXISTS tmp_Msg_Error;


*/
