oracle双循环
循环资源表(T_SYS_RESOURCE)和角色表(T_SYS_ROLE)
插入角色资源表t_sys_role_resource
declare
--a表游标定义
cursor a_SYS_RESOURCE_cur is
SELECT RES_ID FROM T_SYS_RESOURCE START WITH RES_ID IN (SELECT RES_ID FROM T_SYS_RESOURCE WHERE RES_NAME='交易订单查询') CONNECT BY PRIOR RES_ID = PARENT_ID ORDER BY PARENT_ID ASC;
--b表游标定义
cursor b_T_SYS_ROLE_cur is
SELECT ROLE_ID from T_SYS_ROLE;
BEGIN
-- routine body goes here, e.g.
-- DBMS_OUTPUT.PUT_LINE('Navicat for Oracle');
for a_SYS_RESOURCE in a_SYS_RESOURCE_cur loop
EXIT WHEN a_SYS_RESOURCE_cur%NOTFOUND;
for b_T_SYS_ROLE in b_T_SYS_ROLE_cur loop
--执行需要插入的语句
insert into t_sys_role_resource values(erm.seq_sys_role_resource.nextval, b_T_SYS_ROLE.ROLE_ID, a_SYS_RESOURCE.RES_ID, sysdate, sysdate);
end loop;
end loop;
END;