salix/db/routines/hedera/procedures/myOrder_checkMine.sql

21 lines
461 B
SQL

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`myOrder_checkMine`(vSelf INT)
proc: BEGIN
/**
* Check that order is owned by current user, otherwise throws an error.
*
* @param vSelf The order id
*/
DECLARE vIsMine BOOL;
SELECT COUNT(*) > 0 INTO vIsMine
FROM `order`
WHERE id = vSelf
AND customer_id = account.myUser_getId();
IF NOT vIsMine THEN
CALL util.throw('orderNotOwnedByUser');
END IF;
END$$
DELIMITER ;