PL-SQL批量执行立即声明后收集

时间:2015-07-16 12:25:04

标签: oracle plsql

我正在尝试执行下面的声明,但我认为sintax是不对的。执行立即后可以使用批量收集吗?

EXECUTE IMMEDIATE
        'select unique cvc.object_id ' ||
        'from ems.ibo_sm_cvc_rfs cvc,' || 
        'ems.ibo_alcatel_mse_locale poi,' ||
        'ems.ibo_nbn_csa csa,' ||
        'ems.ibo_sm_ean_service_sites_rfs sites,' ||
        'EMS.ibo_sm_ean_service_site_rfs site ' ||
        'where poi.object_name = :1' 
         USING pis_poi_for_cleanup
         BULK COLLECT INTO pona_identified_cvcs;

我得到的错误是通用的:

  

在遇到以下任何一种情况时遇到符号“BULK”:...

1 个答案:

答案 0 :(得分:2)

重写原始答案,在USING语句后移动BULK COLLECT子句:

BEGIN
   EXECUTE IMMEDIATE 'select unique cvc.object_id ' ||
        'from ems.ibo_sm_cvc_rfs cvc,' || 
        'ems.ibo_alcatel_mse_locale poi,' ||
        'ems.ibo_nbn_csa csa,' ||
        'ems.ibo_sm_ean_service_sites_rfs sites,' ||
        'EMS.ibo_sm_ean_service_site_rfs site ' ||
        'where poi.object_name = :1'
        BULK COLLECT INTO pona_identified_cvcs
        USING pis_poi_for_cleanup;
END;
/

您可以扩展此代码,审核此link

希望这有帮助!!!