Oracle

作者: 昵乄称 | 来源:发表于2020-08-11 11:05 被阅读0次

匿名块:

DECLARE
    v_count NUMBER:=0; -- 参数
    i NUMBER:=1; 
BEGIN
   --INSERT INTO a_test SELECT  *  from A_JG;
   -- 代码块
   begin
      loop
        v_count := v_count+1;
        INSERT INTO a_test values (v_count,v_count,v_count,v_count);
         dbms_output.put('2323');  
        EXIT WHEN v_count = 100; -- v_count = 100 时退出循环
      end loop;
   end;
   DBMS_OUTPUT.PUT_LINE('成功录入数据');
   commit;
END;

存储过程:

create or replace PROCEDURE "cccc" (
zrr in varchar2 --责任人
) as 
cur_uuid varchar2(50);--定义uuid
begin
     for c_zrrs in ( select distinct obj from dual) loop  -- 循环
            cur_uuid := sys_guid();
                 INSERT INTO  a (zrr ) VALUES(c_zrrs.obj);
               for  c_zkdzj in ( select str from dual) loop --循环套循环
                INSERT INTO b(zrr ) VALUES ( c_zkdzj.str);
               end loop;
       END LOOP;
end;

级联查询

SELECT * FROM yxsdwxx  START WITH dwid = 'E8D546B0E28147679395B0882F0B4A0D'  
CONNECT BY PRIOR dwid = lsdwh ORDER SIBLINGS BY lsdwh

批量更新

 update T_JS_JSXX t1 set JZGLB =(select SFZZJS from   
 T_JS_JSXX_BACK t2 where t1.jgh=t2.jgh) where exists (select 1 from   
 T_JS_JSXX_BACK t2 where t1.jgh=t2.jgh);  

相关文章

网友评论

      本文标题:Oracle

      本文链接:https://www.haomeiwen.com/subject/wzmedktx.html