Thanks Tom
Edwin, March 17, 2003 - 8:05 pm UTC
Hi Tom,
Thanks for your excellent approach!
I still got someting mix-up in using object type.
What is the advantage of using object type rather than the record type? Since I read many store proc. in oracle application are using record type, so i wonder using record type can enhance the performance of the program.
March 17, 2003 - 8:38 pm UTC
they are programming constructs, not performance tools necessarily.
In this case -- unless you use a SQL object type -- you won't be doing what you are attempting to do, so here the discussion is "moot".
Me, I have never typed in the lines:
type X is record ....
in my entire life. Do I use records in PLSQL? yes --
declare
x table%rowtype;
y cursor%rowtype;
....
but I've never defined my own record. Object types and collections -- all of the time, so I can use SQL on them. User defined record types -- I don't really use them.
A Reader, March 18, 2003 - 5:53 am UTC
Can u please explain CAST and MULTISET.
Thanks
March 18, 2003 - 8:47 am UTC
cast is just a function to tell oracle the datatype expected back. You can cast a number to number(7,2) for example -- or as in this case we are casting a result set as a collection type.
multiset just tells Oracle "hey, this here subquery, it is not a scalar subquery, it'll return many rows possibly".
You use them predominantly as I have above -- to cast a multi-row result set as a collection type.
Using where clause in collection
Mohan K, July 19, 2003 - 2:35 am UTC
In PL/SQL tables it is possible tu user index by integer. Using collection objects in SQL is it possiblt to do the same or is there any other way to create an array with index.
Mohan
July 19, 2003 - 11:39 am UTC
Not in SQL, no.
SQL = sets
PLSQL = procedural.
Q regarding bulk fetching records and then inserting.-
Mariano, April 28, 2004 - 11:28 am UTC
Tom, hi.
I open a cursor, bulk collect its result into two collections with limit 100 and loop this last collection to retrieve info I put into a record (as explained at Expert 1 on 1, chapter 20 pages 895-896 -Apress edition-) and then insert into a nested table column in a table with the info of this collection record.
As example,
open c$1;
<<outer_loop>>
loop
fetch c$1 bulk collect
into r$clu1, r$dt1 limit 100;
exit when c$1%notfound;
<<inner_loop>>
for a in r$clu1.first .. r$clu1.last
loop
select cast(multiset
(<<query here using r$clu1 & r$dt1>>)
into r$resultc1 -- this's like myTableType
from dual;
end loop inner_loop;
end loop outer_loop;
close c$1;
My question: must I insert the record info (r$resultc1) in the destination table after every outer loop (I don't know if the collection record is override in every loop, as the bulk collect limit is 100) or it'll keep the info till the end of the process.
I hope my question makes any sense.
Best regards.-
April 28, 2004 - 5:35 pm UTC
each select into will overwrite whatever was in there previously