我有一个带有以下描述的表产品:
desc products;
Name Null? Type
---------------------- -------- --------------
PID NOT NULL CHAR(4)
PNAME VARCHAR2(15)
PRICE NUMBER(6,2)
DISCNT_RATE NUMBER(3,2)
我的游标语句如下:
declare
cursor c5 is
select pid, pname, price
from products
c5_rec c5%rowtype
group by price for update;
begin
for c5_rec in c5
loop
if(c5_rec.price > 100) then
delete from products where current of c5;
end if;
end loop;
end;
/
当我在第 4 行和第 5 行中不包含 group by 和 rowtype 时,它给了我错误:
integrity constraint (MYID.SYS_C0012393) violated - child record found ORA06512: at line 7
我要做的是编写一个PL/SQL
包含游标的匿名块GROUP BY
,然后在执行部分中对游标的结果表执行更新/删除。在哪里可以添加 group by 子句?我哪里错了?