oracle 游标使用
最近公司需要新建子公司
子公司职务,职级
declare --定义游标 cursor FunctionLevel_cursor is SELECT OBJECTVERSION ,levelvalue,functionlevelname, DESCRIPTION from FunctionLevel WHERE FunctionLevel.Organizationoid = '31b7bb50e1d410048d2b5c0486f08b35'; --定义基数变量 temp VARCHAR(40); temp1 VARCHAR(40); begin --处理游标的循环操作 SELECT OID INTO temp1 FROM ORGANIZATION WHERE ID ='ds38'; for c in FunctionLevel_cursor loop temp:=get_uuid(); dbms_output.put_line(temp||':'||c.OBJECTVERSION || ': ' || c.levelvalue); INSERT INTO FunctionLevel (oid,objectversion,levelvalue,functionlevelname,organizationoid,description) VALUES(temp,1,c.levelvalue,c.functionlevelname,temp1,c.description); end loop; end; declare --定义游标 cursor FunctionDefinition_cursor is SELECT OBJECTVERSION ,functiondefinitionname,shortname, DESCRIPTION from FunctionDefinition WHERE FunctionDefinition.Organizationoid = '31b7bb50e1d410048d2b5c0486f08b35'; --定义基数变量 temp VARCHAR(40); temp1 VARCHAR(40); begin --处理游标的循环操作 SELECT OID INTO temp1 FROM ORGANIZATION WHERE ID ='ds38'; for c in FunctionDefinition_cursor loop temp:=get_uuid(); dbms_output.put_line(temp||':'||c.OBJECTVERSION || ': ' || c.functiondefinitionname); INSERT INTO FunctionDefinition (oid,objectversion,functiondefinitionname,shortname,organizationoid,description) VALUES(temp,1,c.functiondefinitionname,c.shortname,temp1,c.description); end loop; end;
像这种尽量手动提交事务