我是初学者,刚学使用记录类型,哪位可以给我一个在存储过程中应用的小例子,我自己定义的总是有问题,请给个完全的例子,谢谢

解决方案 »

  1.   

    先建表,然后写存储过程是没有问题的; 
    SQL> create table t1(id1 number); 表已创建。 SQL> create or replace procedure p1 
      2  as 
      3    i number:=2; 
      4    m number:=-1; 
      5  begin 
      6    insert into t1 values(3); 
      7  commit; 
      8    select count(*) into i from all_tables where table_name='t1'; 
      9    select id1 into m from t1 where rownum=1; 
    10    if i>0 then 
    11      dbms_output.put_line('good1!'); 
    12    elsif i>1 then 
    13      dbms_output.put_line('good2!'); 
    14    else 
    15        --dbms_output.put_line('good3!'); 
    16        dbms_output.put_line(m); 
    17        execute immediate 'drop table t1'; 
    18        dbms_output.put_line('delete ok !'); 
    19    end if;  
    20  end; 
    21  / 过程已创建。 SQL>