编译报错,不知道是不是%raw type用法不对。teacher是一个表,有teacher_id和teacher_name两个字段。
CREATE OR REPLACE  PROCEDURE showteacher
 as teachInfo teacher %raw type;
 
 begin
 
 select * into teachInfo from teacher where teacher_id = '1';
 
 dbms_output.put_line(teachInfo.teacher_name);
 
 end;

解决方案 »

  1.   

     teachInfo teacher%ROWTYPE;
      

  2.   

    这种方式还是用游标吧:
    CREATE OR REPLACE  PROCEDURE showteacher
     as
     v_cr SYS_refcursor;
     teachInfo teacher%rowtype;
     
     begin
     
     open v_cr for select * from teacher where teacher_id = '1';
     loop
     fetch v_cr into teachInfo;
    exit when v_cr%NOTFOUND;
     dbms_output.put_line(teachInfo.teacher_name);
     end loop;
    close v_cr;
     end;
    /