2
我有一个非常大的SQL语句,它返回一个id列表。我需要这个id列表作为其他语句的基础。像这样:插入并从oracle中的表/数组中选择
open crs_result1 for ' select * from ... where id in (select <ids> from <base_statement>) ';
open crs_result2 for ' select * from ... where id in (select <ids> from <base_statement>) ';
open crs_result3 for ' select * from ... where id in (select <ids> from <base_statement>) ';
...
当然,我不想每次选择不同的选择整个id列表。
所以,我的想法是使用一个表/数组:
TYPE gt_result_rec IS RECORD
(
id NUMBER
);
TYPE gt_result_tab IS TABLE OF gt_result_rec INDEX BY BINARY_INTEGER;
t_results gt_result_tab;
execute immediate 'insert into t_results select <ids> from <base_statement>';
而不是用它为所有其他语句:
open crs_result1 for ' select * from ... where id in (select id from t_results) ';
...
但是,这并不真正发挥作用。
有谁知道这个问题或有更好的解决方案?