Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How to access sql table records in PL/SQL
> I have same problem please let me know if you come to know the answer.
>
> Thanks
>
> News wrote in message <8ILG4.141$k5.63930_at_news.abs.net>...
> >I am a new Oracle user. I want to display the SQL table records in PL/SQL
> >procedure. For which I'm using following
> >
> >Declare
> >v_FirstName varchar2(15);
> >v_LastName varchar2(15);
> >v_Salary number;
> >
> >Begin
> >--Employee is table name & FirstName, LastName, Salary are the fields of
> the
> >table
> >
> >select FirstName, LastName, Salary into v_FirstName, v_LastName, v_Salary
> >from employee;
> >
> >dbms_output.put_line(v_LastName || ' ' || v_FirstName || ' ' || v_Salary);
> >
> >End;
> >/
> >
> >I have multiple records in the employee table. When I run the program I get
> >error multiple records found.
> >If anybody knows, Please let me know.
> >
> >Thanking in advance.
> >
> >Rajashri Jadhav
> >
> >
You need cursors.
Try this (I didn't test it)
declare
Cursor CurData is
select FirstName, LastName, Salary from employee;
dbms_output.enable(1000000);
for RecData in CurData loop
dbms_output.put_line (RecData.FirstName||' '||RecData.LastName||' '||RecData.Salary);
end loop;
end;
Regards, Stephan
--
Dipl.-Inf. (FH) Stephan Born | beusen Consulting GmbH fon: +49 30 549932-0 | Landsberger Allee 392 fax: +49 30 549932-21 | 12681 Berlin mailto:stephan.born_at_beusen.de | Germany --------------------------------------------------------------- PGP-Key verfügbar | PGP-Key available ---------------------------------------------------------------Received on Thu Apr 06 2000 - 10:35:10 CDT
![]() |
![]() |