21 lines
642 B
SQL
21 lines
642 B
SQL
|
|
DROP function IF EXISTS `vn`.`botanicExport_isUpdatable`;
|
|
|
|
DELIMITER $$
|
|
CREATE DEFINER=`root`@`%` FUNCTION `vn`.`botanicExport_isUpdatable`(vEdiGenusFk MEDIUMINT,vEdiSpecieFk MEDIUMINT,
|
|
vCountryFk MEDIUMINT,vRestriction MEDIUMINT) RETURNS int(11)
|
|
DETERMINISTIC
|
|
BEGIN
|
|
DECLARE vIsUpdatable INTEGER;
|
|
SELECT COUNT(*) INTO vIsUpdatable
|
|
FROM botanicExport
|
|
WHERE ediGenusFk = vEdiGenusFk
|
|
AND (vEdiSpecieFk = ediSpecieFk OR IFNULL(vEdiSpecieFk,ediSpecieFk) IS NULL)
|
|
AND (vCountryFk = countryFk OR IFNULL(vCountryFk,countryFk) IS NULL)
|
|
AND vRestriction = restriction;
|
|
RETURN vIsUpdatable;
|
|
END$$
|
|
|
|
DELIMITER ;
|
|
|