Depende de lo que quiera decir con 'solución alternativa'. El tipo deberá declararse a nivel de SQL, no dentro de un bloque PL/SQL (presumiblemente un paquete en este caso). Esto funcionaría, por ejemplo:
CREATE OR REPLACE TYPE t_error_msgs AS TABLE OF VARCHAR2(2000)
/
CREATE OR REPLACE PACKAGE p42 AS
FUNCTION handler RETURN t_error_msgs;
END p42;
/
CREATE OR REPLACE PACKAGE BODY p42 AS
FUNCTION handler RETURN t_error_msgs IS
BEGIN
RETURN null; -- put real data here, obviously...
END handler;
END p42;
/
DECLARE
v_error_msg t_error_msgs;
v_function varchar2(30);
BEGIN
v_function := 'p42.handler';
EXECUTE IMMEDIATE 'BEGIN :result := ' || v_function || '; END;'
USING OUT v_error_msg;
END;
/
Alternativamente, puede reconsiderar si realmente necesita que esto sea dinámico. Presumiblemente, está pasando o determinando de alguna manera la función para llamar sobre la marcha y poblando v_function
. Si hay una lista relativamente corta de valores posibles, podría ser más sencillo tener un case
con llamadas de funciones estáticas individuales.