DROP FUNCTION IF EXISTS mocha_get_instance_key;

CREATE FUNCTION mocha_get_instance_key
(
    p_inst_id INT
)
RETURNS VARCHAR(50)
BEGIN
    RETURN (SELECT CONCAT(class_id, '$', inst_id) FROM mocha_instances WHERE tenant_id = mocha_get_current_tenant() AND id = p_inst_id);
END;




