Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Object extensions Oracle8 - a few questions
At the moment I'm learning how to use the object extensions for Oracle8. I own Personal Oracle8i 8.1.6 running on Win98SE. I was wondering how to do a few things...
Suppose we already have the following structures (don't care about the syntax - it is simplified):
create type BOOKS as table of ref BOOK;
create type BOOK as object (
TITLE varchar2(50),
COUNTER number(5),
SEQUELS BOOKS,
member procedure DO_IT
);
create table LIBRARY of BOOK store nested table SEQUELS as SSS;
My questions are:
1. how to call the method DO_IT() of a specific BOOK from
the LIBRARY, which TITLE is '101 dalmatians'? Is there something like:
exec l.do_it() from library l where title = '101 dalmatians'
2. is it possible for the method DO_IT() to change some fields
of an object to which it belongs? Suppose it has to increment its field COUNTER. Can i do it any simpler than:
fetch book from library into variable where title = '...'
variable.do_it()
replace book in library with variable where title = '...'
3. suppose DO_IT() has to output (using dbms_output.put_line())
the TITLEs of all the SEQUELS of a BOOK to which it belongs. How to write the method then? How to perform a SELECT on the nested table SEQUELS, when it is still treated as a normal field, not a table? I've tried:
create type body BOOK is
member procedure DO_IT is cursor MY_CURSOR is select deref(a) from table(SEQUELS) a; X MY_CURSOR%ROWTYPE; begin for X in MY_CURSOR loop dbms_output.put_line(X.TITLE); end loop; end;
...but it didn't work.
Thanks for attention,
-- @_/ Michal "Bogien/Bogna" Prinke \/\ _ | \ / oo email: bogien_at_conecto.pl, tel: 830-17-21, era gsm: 606 48-75-34 oo g-g: 160130, www: http://www.math.put.poznan.pl/~bogienReceived on Sun May 27 2001 - 16:51:15 CDT