我正在使用Oracle 11g数据库,发布11.2.0.3.0 - 64位生产
我有几个已定义的包,过程,函数和数据类型.在使用集合,数组和其他数据结构进行大量中间计算之后,我最终需要动态创建数据库表以输出我的最终结果.出于这个问题的目的,我有以下内容:
TYPE ids_t IS TABLE OF NUMBER INDEX BY PLS_INTEGER;
benefit_ids ids_t;
--Lots of other code which successfully populates benefit_ids.
--benefit_ids has several million rows, and is used successfully as
the input to the following function:
FUNCTION find_max_ids(in_ids in ids_t)
RETURN ids_t
IS
str_sql varchar2(200);
return_ids ids_t;
BEGIN
str_sql := 'SELECT max(b.benefit_id)
FROM TABLE(:1) a
JOIN benefits b ON b.benefit_id = a.column_value
GROUP BY b.benefit_id';
EXECUTE IMMEDIATE str_sql BULK COLLECT INTO return_ids USING in_ids;
RETURN return_ids; …
Run Code Online (Sandbox Code Playgroud)