原题是这样的(oracle9i实用教程中的练习题)
写一个存储过程,用于创建一个名为Test的表,该表只有一个名字为COLL的列,数据类型为整型,
创建一个循环结构,插入数值到表中,直到有100条记录,用变量记录已存储到表中的记录数,
当变量的值达到100时,使用BREAK语句退出循环。

解决方案 »

  1.   


    create or replace procedure prd_CrTable
    as
      i number(8) default 0;
    begin
      --判断是否有表
      select count(*) into i from user_tables where table_name='TEST';
      if i=0 then    -- 没有表,建表 ,插入数据
        Execute immediate 'create table Test(coll number(8) default 0)';
        loop
          if i=99 then exit;
          else
            Execute immediate 'insert into Text values(:1)' using i;
            i := i+1;
          end if;
        end loop;  
      end if;
    end;
      

  2.   

    如果权限不足,要赋予权限。
    grant   create   any   table   to   user;