27 lines
719 B
MySQL
27 lines
719 B
MySQL
|
DELIMITER $$
|
||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`client_getSalesPersonCode`(vClientFk INT, vDated DATE)
|
||
|
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 ;
|