无法重新打开临时表



当我调用MySQL函数时:'modulo_usuario_verificer_usuario_subset_usuario'作为

SELECT id FROM usuario WHERE modulo_usuario_verificar_usuario_subset_usuario(3, id);

MySQL抱怨:

ERROR 1137 (HY000): Can't reopen table: 'temp_modulo_usuario_obter_organizacoes_usuario'

"modulo_usuario_verificar_uusario_subset_usuario"函数如下所示:

FUNCTION `modulo_usuario_verificar_usuario_subset_usuario`( in_super_usuario int unsigned, in_sub_usuario int unsigned)
RETURNS int(11)
DETERMINISTIC
BEGIN
.....some code here ....
//This SP drops, creates, and populates the temporary table:temp_modulo_usuario_obter_organizacoes_usuario
call modulo_usuario_obter_organizacoes_usuario_c(in_super_usuario);
//Using the temporary table previously created
return (select not exists ( select *
                    from sub_set 
                    where sub_set.org_id not in (   select super_set.org_id
                                                    from temp_modulo_usuario_obter_organizacoes_usuario as super_set)) as super_usuario);
END

我在哪里重复使用临时表?我知道在函数内部它只使用一次,在调用函数的select子句中,函数创建了一个新的临时表

编辑:我刚刚找到了一个很好的答案,为什么我不能这么做:

在函数内部调用过程会引发MySQL ERROR 1422

您在一个存储函数中。可能是在调用函数的查询中使用tmp表。或者您的CALL语句。或者在其他函数调用中。

最新更新