【问题标题】:assignment operation in FORALL clauseFORALL 子句中的赋值操作
【发布时间】:2018-01-26 12:44:04
【问题描述】:

我正在尝试在一些变量计算之后使用带有 FORALL 子句的 INSERT 语句。

更准确地说:

declare
    type t_test_bis is table of test_1%rowtype;
    v_test_bis t_test_bis;

    cursor c_1 is
        select * from test_1;
    i number;
begin

    OPEN c_1;
    LOOP
        FETCH c_1 BULK COLLECT INTO v_test_bis;     
        EXIT WHEN c_1%NOTFOUND;
    END LOOP;
    CLOSE c_1;

    forall j in 1 .. v_test_bis.count
        v_test_bis(i).age := v_test_bis(i).age + 10;  -- is there a way to perform such opperation?
        insert into test_2 values v_test_bis(i);

end;

谢谢,

【问题讨论】:

    标签: oracle plsql forall


    【解决方案1】:

    不,因为 FORALL 语句可能只包含一个 DML 语句,而您有两个(如果您要求的话)。

    【讨论】:

      【解决方案2】:

      forall 将集合绑定到单个 SQL 语句并执行它,这一切都在一个镜头中完成。这不是一个循环,也没有任何设施可以注入任何每行处理步骤。

      相反,您可以编写一个单独的步骤来循环遍历集合并修改forall 之前的每个值。

      【讨论】:

        猜你喜欢
        • 2020-07-21
        • 1970-01-01
        • 2011-07-07
        • 2020-04-16
        • 2018-05-29
        • 2019-03-25
        • 2019-06-27
        • 2011-07-19
        • 1970-01-01
        相关资源
        最近更新 更多