2024-02-08 09:50:56 +00:00
|
|
|
DELIMITER $$
|
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`accountNumberToIban`(
|
2024-02-09 12:38:09 +00:00
|
|
|
vAccount VARCHAR(20)
|
2024-02-08 09:50:56 +00:00
|
|
|
)
|
|
|
|
RETURNS varchar(4) CHARSET utf8mb3 COLLATE utf8mb3_general_ci
|
|
|
|
DETERMINISTIC
|
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* Calcula y genera el código IBAN correspondiente
|
|
|
|
* a un número de cuenta bancaria español.
|
|
|
|
*
|
|
|
|
* @param vAccount Número de cuenta bancaria
|
|
|
|
* @return vIban Código IBAN de 4 caracteres.
|
|
|
|
*/
|
|
|
|
DECLARE vIban VARCHAR(4);
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
CONCAT('ES',
|
|
|
|
RIGHT(
|
|
|
|
CONCAT(0,
|
2024-02-09 12:38:09 +00:00
|
|
|
98-MOD(
|
|
|
|
CONCAT(
|
|
|
|
MOD(
|
|
|
|
CONCAT(
|
|
|
|
MOD(
|
|
|
|
CONCAT(
|
|
|
|
MOD(
|
|
|
|
SUBSTRING(vAccount, 1, 8),
|
|
|
|
97
|
|
|
|
),
|
|
|
|
SUBSTRING(vAccount,9,8)
|
2024-02-08 09:50:56 +00:00
|
|
|
),
|
2024-02-09 12:38:09 +00:00
|
|
|
97
|
|
|
|
),
|
2024-02-08 09:50:56 +00:00
|
|
|
SUBSTRING(
|
|
|
|
CONCAT(vAccount, 142800),
|
|
|
|
17,
|
|
|
|
8
|
|
|
|
)
|
|
|
|
),
|
2024-02-09 12:38:09 +00:00
|
|
|
97
|
|
|
|
),
|
2024-02-08 09:50:56 +00:00
|
|
|
SUBSTRING(
|
|
|
|
CONCAT(vAccount, 142800),
|
|
|
|
25,
|
|
|
|
2
|
|
|
|
)
|
|
|
|
),
|
2024-02-09 12:38:09 +00:00
|
|
|
97
|
|
|
|
)
|
2024-02-08 09:50:56 +00:00
|
|
|
),
|
2024-02-09 12:38:09 +00:00
|
|
|
2
|
|
|
|
)
|
2024-02-08 09:50:56 +00:00
|
|
|
) INTO vIban;
|
|
|
|
|
2024-02-09 12:38:09 +00:00
|
|
|
RETURN vIban;
|
2024-02-08 09:50:56 +00:00
|
|
|
END$$
|
|
|
|
DELIMITER ;
|