DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`printer_checkSector`(vLabelerFk tinyint(3) unsigned, vSector INT(11))
BEGIN
/**
 * Comprueba si la impresora pertenece al sector
 *
 * @param vLabelerFk id de la impresora 
 * @param vSector sector a comprobar
 */
	DECLARE isPrinterInNewSector BOOL;

	IF vLabelerFk IS NOT NULL THEN
		SELECT COUNT(sectorFK) INTO isPrinterInNewSector
			FROM vn.printer p  
				WHERE id = vLabelerFk AND sectorFk = vSector;

		IF !isPrinterInNewSector THEN
			CALL util.throw("PrinterNotInSameSector");
		END IF;
	END IF;
END$$
DELIMITER ;
