2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`item_getFhImage`(itemFk INT)
|
2024-01-15 11:31:03 +00:00
|
|
|
RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci
|
|
|
|
DETERMINISTIC
|
|
|
|
BEGIN
|
|
|
|
DECLARE vImageUrl VARCHAR(255);
|
|
|
|
SELECT sr.PictureReference INTO vImageUrl
|
|
|
|
FROM vn.buy b
|
|
|
|
JOIN edi.ekt e ON b.ektFk = e.id
|
|
|
|
JOIN edi.supplyResponse sr ON sr.Item_ArticleCode =e.`ref`
|
|
|
|
JOIN vn.item i ON i.id = b.itemFk
|
|
|
|
WHERE b.itemFk = itemFk
|
|
|
|
ORDER BY (sr.EmbalageCode = e.package) DESC
|
|
|
|
LIMIT 1;
|
|
|
|
RETURN vImageUrl;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|