Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Rookie question
Hello, Rookie:
With a SELECT statment in a stored program unit you have to use the INTO clause. A SELECT don't have any place to show the results, so they have to be written into a variable.
rsenn <rsenn_at_capaccess.org> wrote in article
<3446B880.7EA9F732_at_capaccess.org>...
> 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 ; -- You cannot do this.
> 5 end test ;
> 6 /
Try this:
> SQL> set serveroutput on
> SQL>
> SQL> create or replace procedure test
> 2 is
> 3 cursor c_1 is select * from emp_hist;
> 4 begin
> 5 for emp_record in c1 loop -- this puts columns' contents
at a record variable
> 6 dbms_output.put_line (emp_record.ename);
> 7 end loop;
> 8 end test ;
> 9 /
> SQL>
> SQL> set serveroutput on
This will work.
DANILO GIMENEZ
danilog_at_mandic.com.br
Sao Paulo - SP - Brasil
Received on Fri Oct 17 1997 - 00:00:00 CDT
![]() |
![]() |