mocha/sql/mysql/000-functions/mocha_get_instance_by_global_identifier.sql

12 lines
396 B
SQL

DROP FUNCTION IF EXISTS mocha_get_instance_by_global_identifier;
CREATE FUNCTION mocha_get_instance_by_global_identifier
(
p_global_identifier CHAR(40)
)
RETURNS INT
DETERMINISTIC
RETURN (
SELECT id FROM mocha_instances WHERE tenant_id = mocha_get_current_tenant()
AND mocha_normalize_uuid(global_identifier) = mocha_normalize_uuid(p_global_identifier)
ORDER BY id DESC LIMIT 1);