传递一个表在oracle中的execute命令中运行

时间:2014-11-10 19:41:15

标签: sql oracle

我需要写下面的多个语句

EXECUTE ssc.iqv_calculation ('PWCD_PRODUCT_CATEGORY', 'PRODUCT_CATEGORY');
EXECUTE ssc.iqv_calculation ('PWCD_CONTRACTING_LOCATION', 'CONTRACTING_LOCATION');
EXECUTE ssc.iqv_calculation ('PWCD_CNTRY_INCORPORATION', 'CNTRY_INCORPORATION');
EXECUTE ssc.iqv_calculation ('PWCD_COUNTRY_OF_OPERATIONS', 'COUNTRY_OF_OPERATIONS');
EXECUTE ssc.iqv_calculation ('PWCD_XBORDER_ACTIVITY', 'XBORDER_ACTIVITY');
EXECUTE ssc.iqv_calculation ('PWCD_APPROVED_EXCHANGE', 'APPROVED_EXCHANGE');
EXECUTE ssc.iqv_calculation ('PWCD_LEGAL_STRUCTURE', 'LEGAL_STRUCTURE');

这些很少,但我需要写100条这样的陈述。

如果我有一个包含两列的表,其中包含两个参数的列表,我怎么能在循环中发送它们。

一种方法是优秀。我怎么能在Oracle本身做到这一点。

1 个答案:

答案 0 :(得分:1)

begin
    for rec in (select param1, param2 from your_table) loop
        execute immediate 'begin ssc.iqv_calculation(:1, :2); end;'
            using
            in rec.param1,
            in rec.param2;
    end loop;
end;
/

享受。