• 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;

    像这种尽量手动提交事务

  • 相关阅读:
    [ABC200E] Patisserie ABC 2
    [CF1521E] Nastia and a Beautiful Matrix
    [CF1498D] Bananas in a Microwave
    [CF1515B] Phoenix and Puzzle
    [CF1519C] Berland Regional
    [CF1519B] The Cake Is a Lie
    [ZONe Energy Programming Contest C] MAD TEAM
    [洛谷P7480] Reboot from Blue
    [CF1508A] Binary Literature
    1371. 货币系统
  • 原文地址:https://www.cnblogs.com/chenzhelove/p/13527260.html
Copyright © 2020-2023  润新知