数据库:oracle
create or replace procedure test_procedure-->//存储过程名称
is
CURSOR temp IS select aa,bb,cc from table_test;--> //temp:查询出来的数据集合,aa,bb,cc:需要查询的字段,table_test:表名
Begin-->//数据库关键字,循环开始的标识
FOR i IN temp LOOP-->//for循环
update table_test2 set dd=i.aa where ee=i.aa;--> //table_test2:需要更新的表名,dd:需要更新的字段,ee=i.aa:这两个表的关联字段,一般是主键关联
END LOOP;
End;-->//数据库关键字,存储过程结束
call test_procedure();--> //执行存储过程
commit;--//提交数据