Oracle database using cursors

Example:
acquired simultaneously containing the names of all hierarchy mechanisms (this list is only a name, and have a hierarchy node / pnode), and then inserted into another table.
DECLARE

CURSOR ybs IS SELECT organ_code "orc",node "pnode" FROM SYS_ORGAN;

BEGIN

FOR yb IN ybs LOOP

INSERT INTO SYS_ORGAN_ORGAN(sys_id,db_key,tb_key,organ_code,manage_type,manage_organ_code,manage_organ_name,node,pnode)
SELECT sys_guid(),'0','0',yb."orc",'COMMON',organ_code,organ_name,node,pnode FROM SYS_ORGAN WHERE node LIKE (yb."pnode"||'%');
COMMIT;

END LOOP;
END;

Guess you like

Origin www.cnblogs.com/dreamfly6/p/11777585.html