ORACLE-死循环

 

SQL>declare

    v1 int :=10;

    begin

    while v1>1 loop

    insert into t1 select  sysdate from dual;

    v1:=v1+1;

If mod(v1,5)=0 then

Commit;

End if;

     end loop;

    end;

    /

 

SQL> create table t1 (n1 date);

 

Table created.

 

SQL> insert into t1 select sysdate from dual;

 

1 row created.

 

SQL> commit;

 

Commit complete.

 

SQL> select to_char(n1,'yyyy-mm-dd hh24:mi:ss') from t1;

 

TO_CHAR(N1,'YYYY-MM

-------------------

2014-09-17 15:51:16

 

 

TEST @ prod >declare

  2  v1 int :=10;

  3  begin

  4  if v1 >1  then

  5  loop

  6  insert into t1 values(v1);

  7  v1:=v1+1;

  8  end loop;

  9  end if;

 10  end;

 11  /

创建时间:2022-03-30 20:53
浏览量:0