Hi,
I have a a problem with the following procedure used as a test for
larger procedure (which if gets any larger will start answering all the
questions of the universe :-)
I am looking primarily to fetch a cursor into a collection of more than
one column. However, there is some problem with declaration part. Oracle
refuses to recognise my_book_rec_tab.title etc.
Can you please help me out?
Thanks in advance
Abhi
create table book
(title varchar2(20),
author_last_name varchar2(20),
published_date date);
------------------------------------------------
create or replace procedure book_procedure is
--Define a PL/SQL record type representing a book:
TYPE book_rec IS record
(title book.title%TYPE,
author book.author_last_name%TYPE,
published_date book.published_date%TYPE);
--define a PL/SQL table containing entries of type book_rec:
Type book_rec_tab IS TABLE OF book_rec ---- TABLE OF book_rec%TYPE --
also not working
INDEX BY BINARY_INTEGER;
my_book_rec_tab book_rec_tab;
cursor book_cur is
select * from book;
begin
open book_cur;
loop
fetch book_cur
bulk collect into my_book_rec_tab.title , my_book_rec_tab.author,
my_book_rec_tab.published_date;
end loop;
close book_cur;
end;
------------------------------
insert into book values( 'title1', 'last_name1', '02-Nov-2006' );
insert into book values( 'title2', 'last_name2', '01-Nov-2006' );
insert into book values( 'title3', 'last_name3', '31-Oct-2006' );
insert into book values( 'title4', 'last_name4', '30-Oct-2006' );
insert into book values( 'title5', 'last_name5', '29-Oct-2006' );
insert into book values( 'title6', 'last_name6', '28-Oct-2006' );
insert into book values( 'title7', 'last_name7', '27-Oct-2006' );
insert into book values( 'title8', 'last_name8', '26-Oct-2006' );
insert into book values( 'title9', 'last_name9', '25-Oct-2006' );
insert into book values( 'title10', 'last_name10', '24-Oct-2006' );
insert into book values( 'title11', 'last_name11', '23-Oct-2006' );
insert into book values( 'title12', 'last_name12', '22-Oct-2006' );
insert into book values( 'title13', 'last_name13', '21-Oct-2006' );
insert into book values( 'title14', 'last_name14', '20-Oct-2006' );
insert into book values( 'title15', 'last_name15', '19-Oct-2006' );
insert into book values( 'title16', 'last_name16', '18-Oct-2006' );
insert into book values( 'title17', 'last_name17', '17-Oct-2006' );
insert into book values( 'title18', 'last_name18', '16-Oct-2006' );
insert into book values( 'title19', 'last_name19', '15-Oct-2006' );
insert into book values( 'title20', 'last_name20', '14-Oct-2006' );
commit;
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
www.wipro.com
Oracle LazyDBA home page