这个存储过程怎么写?(oracle)刚接触oracle哈table A
id num
01 1
02 2
03 3
需更新A表,得到如下结果(也就是说02=01+02 计算完成后 03=02+03)id num
01 1
02 3
03 6
id num
01 1
02 2
03 3
需更新A表,得到如下结果(也就是说02=01+02 计算完成后 03=02+03)id num
01 1
02 3
03 6
select id,sum(num)over(order by id) num from temp
for c in select id,sum(num)over(order by id) num from a
loop
update a set a.num = c.num where id = a.id;
commit;
end loop;
想要一个完整的存储过程
由于刚接触oracle。
谢谢!
create or replace procedure yourprocedureName
is
begin
for c in select id,sum(num)over(order by id) num from a
loop
update a set a.num = c.num where id = a.id;
end loop;
commit;
end;
CREATE[OR REPLACE] PROCEDURE<过程名>
<参数1>,「方式l]<数据类型1>,
<参数2>,[ 方式2]<数据类型2>,
……)
IS|AS is_或as完全等价
BEGIN
PL/SQL过程体
END<过程名>
找本书看一下就好了.
<参数1>,「方式l]<数据类型1>,
<参数2>,[ 方式2]<数据类型2>,
……)
IS|AS is_或as完全等价
BEGIN
PL/SQL过程体
END<过程名>