27 lines
618 B
MySQL
27 lines
618 B
MySQL
|
DELIMITER $$
|
||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `sage`.`company_getCode`(vCompanyFk INT)
|
||
|
RETURNS int(2)
|
||
|
NOT DETERMINISTIC
|
||
|
READS SQL DATA
|
||
|
BEGIN
|
||
|
/**
|
||
|
* Devuelve la correspondencía del código de empresa de sage.
|
||
|
* Tiene en cuenta el entorno
|
||
|
*
|
||
|
* @param vSelf Id de empresa de verdnatura
|
||
|
* @return Código de empresa sage
|
||
|
*/
|
||
|
DECLARE vCompanySageFk INT(2);
|
||
|
|
||
|
SELECT IF(c.environment = 'production',
|
||
|
co.companyCode,
|
||
|
co.companyCodeTest
|
||
|
) INTO vCompanySageFk
|
||
|
FROM util.config c
|
||
|
JOIN vn.company co
|
||
|
WHERE co.id = vCompanyFk;
|
||
|
|
||
|
RETURN vCompanySageFk;
|
||
|
END$$
|
||
|
DELIMITER ;
|