2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-07-22 09:52:42 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` FUNCTION `vn`.`client_getSalesPersonCode`(vClientFk INT, vDated DATE)
|
2024-01-15 11:31:03 +00:00
|
|
|
RETURNS varchar(3) CHARSET utf8mb3 COLLATE utf8mb3_general_ci
|
|
|
|
DETERMINISTIC
|
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* Dado un id cliente y una fecha, devuelve su comercial.
|
|
|
|
* Para más información ir a client_getSalesPerson()
|
|
|
|
*
|
|
|
|
* @param vClientFk El id del cliente
|
|
|
|
* @param vDated Fecha a comprobar
|
|
|
|
* @return El código del comercial para la fecha dada
|
|
|
|
**/
|
|
|
|
DECLARE vWorkerCode CHAR(3);
|
|
|
|
DECLARE vSalesPersonFk INT;
|
|
|
|
|
|
|
|
SET vSalesPersonFk = client_getSalesPerson(vClientFk, vDated);
|
|
|
|
|
|
|
|
SELECT code
|
|
|
|
INTO vWorkerCode
|
|
|
|
FROM worker
|
|
|
|
WHERE id = vSalesPersonFk;
|
|
|
|
|
|
|
|
RETURN vWorkerCode;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|