Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Rookie question
On Thu, 16 Oct 1997 19:59:45 -0500, rsenn <rsenn_at_capaccess.org> wrote:
>Can anybody tell me why these statements are generating errors?
> Thanks.
>
>SQL> create or replace procedure test
> 2 is
> 3 begin
> 4 select * from emp_hist ;
> 5 end test ;
> 6 /
>
>Warning: Procedure created with compilation errors.
Probably the error is becaues you are selecting data without a destination. Within pl/sql you can't just select data, you need to specify a place to put it. One option is to do a singleton select like this one:
create or replace procedure test is v_emp_name varchar2(30); begin select emp_name into v_emp_name from emp_hist where emp_id=1; end; /
The other option, if you need to deal with a number of rows, is to use a cursor.
regards,
Jonathan Gennick