正如Amarillo所说,您不能动态执行本地定义的过程,因为动态部分将使用的SQL范围中不存在该过程。
您所描述的情况是,所有过程都在匿名块的
DECLARE部分中定义,并且您正在运行一个查询,该查询告诉您要执行的过程-
大概还为您提供了要传递的参数。您可以只使用
if/
else构造或
case语句来执行适当的过程,例如:
DECLARE ...BEGIN FOR data IN (SELECt procname, arg1, arg2, ... from <your_query>) LOOP CASE data.procname WHEN 'OPENLOG' THEN openlog(data.arg1); WHEN 'WRITELOG' THEN writelog(data.arg1, data.arg2); WHEN ... ... ELSE -- handle/report an invalid procedure name -- or skip the `ELSE` and let CASE_NOT_FOUND be thrown END CASE; END LOOP;END;/
您只需要一个
WHEN条件和每个过程的适当过程调用。您也可以
ELSE捕获任何意外的过程名称,或者
CASE_NOT_FOUND抛出异常(ORA-06592),这取决于发生这种情况时需要发生的情况。



