正在学习存储过程, 如果只查询一个字段后面接上into没问题, 现在我想查询表里面所有记录? 在执行存储过程select处老是报错?
Error: PL/SQL: ORA-00923: FROM keyword not found where expected有一张表person, 结构如下:
id varchar2(10),
pname varchar2(10),
salary number(10,2)编写的存储过程如下
create or replace procedure queryAllPerson
is
p_id person.id%type;
p_pname person.pname%type;
p_salary person.salary%type;
begin
  select id into p_id,pname into p_pname,salary into p_salary
  from person;
end queryAllPerson;

解决方案 »

  1.   

    csdn发贴自己怎不能修改自己?  上面搞错了! 重新问问题:)有一张表person,   结构如下: 
    id   varchar2(10), 
    pname   varchar2(10), 
    salary   number(10,2) 我想查询表里面所有记录?  我写的存储过程怎么测试会没数据啊?  提示错误是:
    ORA-0131 Insufficient  Privileges
    Note: Debugging  requires  the  DEBUG  CONNECT  SESSION  system  Privilege存储过程代码:
    create or replace procedure queryPerson
    is
    p_id person.id%type;
    p_pname person.pname%type;
    p_salary person.salary%type;
    begin
      select id,pname,salary into p_id,p_pname,p_salary     
      from person; 
    end queryPerson; 
      

  2.   

    在Pl/sql右击这个过程,弹出菜单选DEbug模式,在PL/SQL调试才可以debug
      

  3.   

    查询所有的要用游标,create   or   replace   procedure   queryPerson 
    is 
    p_id   person.id%type; 
    p_pname   person.pname%type; 
    p_salary   person.salary%type; 
    type mycursor is ref cursor; 
    begin 
        open mycursor for
        select   id,pname,salary           
        from   person;   
    end   queryPerson;   
      

  4.   

    楼上的存储过程, 我在oracle 10g执行会出错哦, 
    Error: PLS-00330: invalid use of type name or subtype name存储过程怎么这么麻烦, 不知大家是怎么学会的? 网上搜了一点资料, 发现都不实用, 大家有没好一点资料推荐一下
      

  5.   

    create or replace procedure queryPerson is
    p_id person.id%type;
    p_name person.name%type;
    p_salart person.salary%type;
    cursor p_cursor is (select p.id,p.name,p.salary from person p);
    begin
       open p_cursor;
       loop
       fetch p_cursor into p_id,p_name,p_salart;
       exit when p_cursor%notfound;
       dbms_output.put_line('id' || to_char(p_id) || 'name' || to_char(p_name) || 'salary' || to_char(p_salart));
       end loop;
       close p_cursor;
    end queryPerson;
      

  6.   

    create or replace procedure queryPerson1 is
    p_data person%rowtype;
    type p_cursor is ref cursor;
    c1 p_cursor;
    begin
      open c1 for 'select * from person';
      loop
      fetch c1 into p_data;
      exit when c1%notfound;
      dbms_output.put_line('id: '||to_char(p_data.id)||' name: '||to_char(p_data.name));
      end loop;
      close c1;
    end queryPerson1;